Solved

Pause and resume a midi

Posted on 2000-04-05
4
757 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 50 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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

770 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