The simplest way to implement MIDI music looping (not to process in MCI callbacks)

Source: Internet
Author: User

A few days ago, you need to play a midi music Loop in a Delphi applet. Why not MP3 or WAV or other? Because the MIDI format is small in size. (In short I have my inevitable reason, more spray nonsense meaning)

The playback feature is selected using the mciSendString function in MMSystem, and notice that the "OPEN" operation requires the media type "type SEQUENCER" (that is, MIDI audio), and then use the "Play XX REPEAT"Operation want to be able to loop playback, the results not only did not realize the cycle, and music is not playing at all. Check MSDN found that "REPEAT" parameter only applies to video media, sequencer, etc. does not apply, there is no way to do it?

Online access to know can be implemented in the "mm_mcinotify" callback event, just for a loop to deal with callbacks, the display does not meet the minimalist style of doing things. Continue Google (Fortunately, the company has a VPN), and finally find the cattle to provide answers (portals), the practice is too clever: since MSDN said repeat parameter only for video, then I will let you play by the video, a MIDI music is not a video of the picture? So the method is in the "OPEN" operation when the media type is specified as "typeMPEGVideo" (Other video formats can also be OK, I do not want to try more), done!


The key code is as follows:

    mciSendString (' OPEN music.mid TYPE mpegvideo ALIAS BGM ', nil, 0, 0);    mciSendString (' PLAY BGM REPEAT ', nil, 0, 0);

Resources:

Http://www.developerfusion.com/thread/41619/repeatloop-midi


The simplest way to implement MIDI music looping (not to process in MCI callbacks)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.