?
Solved

Pause and resume a midi

Posted on 2000-04-05
4
Medium Priority
?
799 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
ID: 2687903
Use the MCI command string "pause" or "stop" to pause and "play" without "from position" to resume.
0
 
LVL 33

Author Comment

by:hongjun
ID: 2688299
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
ID: 2688300
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 150 total points
ID: 2688338
1. Using lstrlen(lpszReturnString) for the 3rd parameter of mciSendString is wrong. Use 30 instead.

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

864 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