Err = Pm_OpenOutput(&(self. Midi), self. I, NULL, 0, PmPtr, NULL, latency) The API documentation shows Pm_OpenOutput having the following signature PmError Pm_OpenOutput ( PortMidiStream **stream, PmDeviceID outputDevice, void *outputDriverInfo, long bufferSize, PmTimeProcPtr time_proc, void *time_info, long latency ) There doesn't appear to be any obvious way to find out the current buffer stack length, and more importantly, it would appear that the Python wrapper ignores the buffer setting entirely anyway portmidi.
C tells a slightly different tale: if (bufferSize queue = Pm_QueueCreate(bufferSize, sizeof(PmEvent)); if (!midi->queue) { /* free portMidi data */ *stream = NULL; pm_free(midi); err = pmInsufficientMemory; goto error_return; } So, 256 is the default. Which would explain why you're running into problems around 100 or so However, something to keep in mind - MIDI is extremely slow, 31250 baud (31250 bits per second), since MIDI messages are (usually) 2 bytes (16 bits), that means a maximum of 1953 messages per second. (I may be wrong here, but I'm pretty close if I'm not right) However, there is hope: A simple fix is, you can sleep down to 2ms on most operating systems without messing things up time.
Sleep(.002) # 2 millisecond sleep However, since you're using write_short(), that would only give you 500 messages per second.So you might want to do something like have a queue that is polled every .002 seconds for outgoing messages, pop 16 off the stack, write them and then sleep. That way if your whole MIDI stack supports rates that fast you could get 8000 messages per second I noticed that in the following code, if I dropped the sleep time lower than .002, no MIDI would be sent at all until I exited the program, then all the events spewed onto the MIDI BUS. So there might be an issue with portmidi rate-limiting, or on OSX One other thing to keep in mind, if you're really blasting MIDI - most likely control-change values, if you're modifying something like a a value of '1' sounds a lot like '2', so if you make your messages less granular (increment or decrement by 2 or 4), you can cut down the number of messages without having a noticeable difference in the audio.
This is a suboptimal solution, and in all likelihood your MIDI stack probably supports much faster than 31250 baud Another thing to consider is that if you slave your portmidi application to the MIDI clock, you can get a reliable stream of ticks from the MIDI host, which you could use as the trigger to write MIDI data back out, (no sleeps necessary) Good luck! N PPQN Clock MIDI 1.0.
Err = Pm_OpenOutput(&(self. Midi), self. I, NULL, 0, PmPtr, NULL, latency) The API documentation shows Pm_OpenOutput having the following signature PmError Pm_OpenOutput ( PortMidiStream **stream, PmDeviceID outputDevice, void *outputDriverInfo, long bufferSize, PmTimeProcPtr time_proc, void *time_info, long latency ) There doesn't appear to be any obvious way to find out the current buffer stack length, and more importantly, it would appear that the Python wrapper ignores the buffer setting entirely anyway.
Portmidi. C tells a slightly different tale: if (bufferSize queue = Pm_QueueCreate(bufferSize, sizeof(PmEvent)); if (!midi->queue) { /* free portMidi data */ *stream = NULL; pm_free(midi); err = pmInsufficientMemory; goto error_return; } So, 256 is the default. Which would explain why you're running into problems around 100 or so.
However, something to keep in mind - MIDI is extremely slow, 31250 baud (31250 bits per second), since MIDI messages are (usually) 2 bytes (16 bits), that means a maximum of 1953 messages per second.(I may be wrong here, but I'm pretty close if I'm not right) However, there is hope: A simple fix is, you can sleep down to 2ms on most operating systems without messing things up.Time. Sleep(.002) # 2 millisecond sleep However, since you're using write_short(), that would only give you 500 messages per second. So you might want to do something like have a queue that is polled every .002 seconds for outgoing messages, pop 16 off the stack, write them and then sleep.
That way if your whole MIDI stack supports rates that fast you could get 8000 messages per second. I noticed that in the following code, if I dropped the sleep time lower than .002, no MIDI would be sent at all until I exited the program, then all the events spewed onto the MIDI BUS. So there might be an issue with portmidi rate-limiting, or on OSX.
One other thing to keep in mind, if you're really blasting MIDI - most likely control-change values, if you're modifying something like a a value of '1' sounds a lot like '2', so if you make your messages less granular (increment or decrement by 2 or 4), you can cut down the number of messages without having a noticeable difference in the audio. This is a suboptimal solution, and in all likelihood your MIDI stack probably supports much faster than 31250 baud. Another thing to consider is that if you slave your portmidi application to the MIDI clock, you can get a reliable stream of ticks from the MIDI host, which you could use as the trigger to write MIDI data back out, (no sleeps necessary).
Good luck! -n PPQN Clock MIDI 1.0.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.