Solved

Pause and resume a midi

Posted on 2000-04-05
4
786 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

705 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