Solved

Pause and resume a midi

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create string splitting user defined function in C++ 23 337
FMX enumerated colours 2 136
Android development question 2 79
How do i run a c++ file? 15 52
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

733 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