Solved

Pause and resume a midi

Posted on 2000-04-05
4
739 Views
Last Modified: 2008-03-04
#include <stdio.h>
#include <time.h>
#include <windows.h>
#include <mmsystem.h>
#include <conio.h>

void main()
{
      char* ReturnString = (char*)malloc(30 *sizeof(char));
      int i=1;

      LPTSTR lpszReturnString = ReturnString;
      mciSendString("open a.mid type sequencer alias finch",
               lpszReturnString, lstrlen(lpszReturnString), NULL);
      mciSendString("set finch time format samples", lpszReturnString,
               lstrlen(lpszReturnString), NULL);
      mciSendString("play finch", lpszReturnString,
               lstrlen(lpszReturnString), NULL);

a = getchar();
if ( a  == 13 )
      mciSendString("close finch", lpszReturnString,
              lstrlen(lpszReturnString), NULL);
}

The above code will open a midi and then play it. And whenever someone hits the RETURN key, the midi will be closed. But may I know how to implement more functions like pause the midi whenever someone presses the Esc, and resume it from where the midi stops whenever someone presses a SPACEBAR.

Thanks in advance
hongjun
0
Comment
Question by:hongjun
  • 2
  • 2
4 Comments
 
LVL 23

Expert Comment

by:chensu
Comment Utility
Use the MCI command string "pause" or "stop" to pause and "play" without "from position" to resume.
0
 
LVL 33

Author Comment

by:hongjun
Comment Utility
Can you code down the exact syntax of the string? Actually I know that the pause will pause a midi, a stop or close will stop a midi, and a resume will resume a midi. It is just that I do not know the syntax.

Thanks
hongjun
0
 
LVL 33

Author Comment

by:hongjun
Comment Utility
Can you code down the exact syntax of the string? Actually I know that the pause will pause a midi, a stop or close will stop a midi, and a resume will resume a midi. It is just that I do not know the syntax.

Thanks
hongjun
0
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
Comment Utility
1. Using lstrlen(lpszReturnString) for the 3rd parameter of mciSendString is wrong. Use 30 instead.

2. "pause finch" and "play finch".
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now