1

After resolving the problem with noteOn key event (thank you Justin) i noticed another two problems: too high delay and impossible playing simultaneously.

Firstable i use IF statment:

if (nutka == "A0" && msg.Velocity != 0) {
    clock.Schedule(new NoteOnMessage(outputDevice, Channel.Channel1, Pitch.A0, 80, 2));
}

and this works excelent, no delay, but it also allows me to use only MIDI Pitch not a .wav files.

when i use other possibility to play a note (from files added to Resources):

SoundPlayer noteA0 = new SoundPlayer(Properties.Resources.A0);
noteA0.Play();

looks and works OK but SoundPlayer don't allow me to play notes simultaneously.

Another way i was trying was WMP library:

var noteA0 = new WMPLib.WindowsMediaPlayer();
noteA0.URL = @"c:\sounds\piano\A0.wav";

Ok... it plays simultaneous but kind a funny thing happens, the more notes i play the bigger delay (delay between i press a key and i hear the sound) i have and finally my programm stuck on playing anything (still got noteOn messages)...looks like the memory buffer was suddenly gone or something like that?

The last thing i was trying to check was DirectX library:

Audio noteA1 = new Audio(@"C:\sounds\piano\A1.wav");
noteA1.Play();

Build and compile - with no problems, without any errors, but when i pressed a key on my midi device, application returns message:

An unhandled exception of type 'System.BadImageFormatException' occurred in Midi.dll
Additional information: Could not load file or assembly 'Microsoft.DirectX.AudioVideoPlayback.dll' or one of its dependencies. 
It is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

My question is - is it possible to add my files (.wav) to Solution Resources and play them simultaneously with delay which will allow me to play like with normal piano? Normal piano i mean with low delay, almost unnoticeable delay.

Martin
  • 79
  • 10
  • Very confusing question: titled with `midi.net` (btw, isn't there a tag for it?), where you try to play `wav`, where you have problem to play 2 wavs (??) and finally you ask how to add it to resources. Good luck with that. Have you consider to solve one problem at a time? E.g. [I have problem to extract resource into a file](http://stackoverflow.com/a/864276/1997232). – Sinatr Jun 26 '15 at 11:29
  • I do not have a problem to add a file to Resources, and i didn't ask for that :) my problem is to play simultaneously and with low delay files added to Resources by the use of Midi-dot-net library (you probably misunderstand my question Sinatr). – Martin Jun 26 '15 at 13:29
  • *to play simultaneously and with low delay files added to Resources by the use of Midi-dot-net library* - I count more than one problem. Which one you want to solve? [Playing simultaneously](http://stackoverflow.com/q/15513599/1997232) , [low delay](http://stackoverflow.com/q/14414271/1997232) or something else? – Sinatr Jun 26 '15 at 13:37
  • I want to resolve too high delay while i am playing simultaneously .wav files. (remember that i am using midi-dot-net library and external midi usb keyboard). That is one problem. – Martin Jun 27 '15 at 08:20
  • 1
    This really doesn't have anything to do with the midi-dot-net library as it doesn't play audio files, Try [this example](http://stackoverflow.com/questions/5747086/playing-two-sounds-simultaneously-c-sharp) for playing simultaneous files. – Justin Ryan Jun 27 '15 at 21:22

0 Answers0