The most intelligent Java IDE
The moose likes Java in General and the fly likes Multiple Midi Channels Problem The Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Essential GWT this week in the GWT forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Multiple Midi Channels Problem" Watch "Multiple Midi Channels Problem" New topic
Author

Multiple Midi Channels Problem

Panos Katergiathis
Greenhorn

Joined: Sep 23, 2009
Posts: 3
Hello all.

I am not sure where should i post this. It may be a threading problem, or it may be a Java Sound problem, or it may be a Java bug (yeah... right).

The following lines of code aiming to use a midi synthesizer in order to have it play random notes.
If i use this code routing midi to any hardware port, it works fine.
If i use it to route midi to "Java Software Synthesizer" device, i can only use one (out of 16) midi channels of this device: should i attempt to concurrently use any second (or third) channel, the program breaks, and i am getting the following error:

"Invalid memory access of location 0x22795d32c rip=0x7fffffe00eca"

Please note the lines that start with "new Player".
Commenting all of them (except one), results in sending midi to one channel only - thus, no problem.
Un-commenting two lines, thus evoking a second "player" causes the error.

I tried it on Snow Leopard and on Windows, it gives a similar "invalid memory" error.
I fear that all this trouble has to do with my less-than-perfect knowledge on threading, so i would appreciate any help.

Kind Regards,
Panos



The code:


Ankit Garg
Bartender

Joined: Aug 03, 2008
Posts: 7694
Protocol Webmaster please check your private messages for some administrative matter...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg
Bartender

Joined: Aug 03, 2008
Posts: 7694
Thanks Panos for changing your display name.

Please tell when you post the same question to another site. This question has been asked here.

Anyways, I don't have any idea about this. Maybe the Java Sound Synthesizer is not multitimbral (cannot play simultaneously on multiple channels), this is all that I can predict. I found a few pages which might be helpful

MIDI FAQ
MIDI Overview

This message was edited 1 time. Last update was at by Ankit Garg

Panos Katergiathis
Greenhorn

Joined: Sep 23, 2009
Posts: 3
The question has also been asked at the DZone forums.
It is not answered anywhere (until now) and i will notify here if and when it does, so that no one will waste any time.



Ankit Garg
Bartender

Joined: Aug 03, 2008
Posts: 7694
I played around with your program and now I'm able to generate multiple sounds simultaneously. What I did was instead of opening the MidiDevice multiple times, I opened it once and and started multiple threads send messages to that MidiDevices receiver. That is this code was run only once



And then I started 4 threads to send ShortMessage to send messages to this Receiver object. Your technique called this code multiple times so maybe the second time you open the Java Sound Synthesizer device, that created problems...
Panos Katergiathis
Greenhorn

Joined: Sep 23, 2009
Posts: 3
I will try this very soon, and provide feedback.
Thank you for assisting.

Panos

 
aspose file troubles
 
subject: Multiple Midi Channels Problem
 
IntelliJ open source