[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to receive MIDI TimeCode (MTC) using DirectX / DirectMIDI?

Posted on 2009-05-11
4
Medium Priority
?
1,309 Views
Last Modified: 2013-12-14
My application uses the library DirectMidi to receive MIDI messages using DirectX. The main purpose is to receive MTC (MIDI TimeCode) that allows my application to sync to a master. Currently I am experiencing performance problems which I want to solve.

Setup:
1) Timing Master: Sonar LE, sending MTC over MIDI
2) MIDI Driver: MidiYoke (http://www.midiox.com/myoke.htm)
3) Client: myApp
4) OS: WindowsXP
5) Language: C++ using Visual Studio .NET 2003
6) MIDI lib: DirectMidi (http://directmidi.sourceforge.net/)

As you can see, I am currently not using any MIDI hardware, but a pure software solution. The MidiYoke driver is tunneling the MIDI messages from the master (Sonar) to the client (myApp). All applications reside on the same machine currently.

Although I can receive MIDI messages well and extract the TimeCode, my application is suffering from severe performance breakdowns. Whereas Sonar is using as little as 5% CPU load in playback, my application is consuming all the remaining CPU power. That means if I visualize the CPU load using the Windows task manager, it is up to 100% as soon as my application starts receiving the MIDI messages.

I tracked the performance consumption down to the location where I actually read the MIDI messages. It is the method "read" of the interface IDirectMusicPort8. So I can exclude that any of my top level processing inside my application is causing the high CPU load.

What I wonder now, is:

1) Could 100% CPU load be the normal behaviour? I mean, I am not only receiving MIDI notes, but tons of MIDI messages a second (MTC). But then, why does Sonar only consum 5% CPU load when it is sending those messages?
2) Could the problem be located in the MidiYoke driver? Does anyone have experience with that? If the driver is the problem, then it should not occur if I am using real MIDI hardware, i.e. an USB MIDI interface. However, I don't want to buy one yet.
3) Any other ideas? Did anyone successfully implement MTC reception over DirectX?


I hope one of the experts can help.
0
Comment
Question by:hirnsieb
[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
4 Comments
 
LVL 20

Accepted Solution

by:
ikework earned 2000 total points
ID: 24369352
i guess your application is in a loop, where it receives the data, even if it does not receive anything, it is in that loop. put it to sleep for some milliseconds with "Sleep"

http://msdn.microsoft.com/en-us/library/ms686298(VS.85).aspx

ike
0
 
LVL 1

Author Closing Comment

by:hirnsieb
ID: 31580063
Got it! ikework's suggestion was a good hint. Although the sleep() wouldn't do it (would delay the whole application), it made me have a closer look at the receiving loop in the DirectMidi library. And guess what!? There was a loop like "while (active) receive MIDI data". The actual event handling of receiving midi data that would put my thread to sleep until the next midi event is available was outside of that loop. Therefore it ran up to 100% all the time.

I should inform the guy who wrote that code. I guess he never handled MTC... ;-)

Thanks!
0

Featured Post

Technology Partners: 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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

649 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