The most intelligent Java IDE
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Win a copy of JBoss AS 5 Development this week in the JBoss forum
or Spring Dynamic Modules in Action in the Spring forum!
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Java in General
 
RSS feed
 
New topic
Author

Multiple Midi Channels Problem

Panos Katergiathis
Greenhorn

Joined: Sep 23, 2009
Messages: 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
Messages: 5911

Protocol Webmaster please check your private messages for some administrative matter...

SCJP 6.0 98%, SCWCD 5 98%, Javaranch SCJP FAQ, SCWCD Links
The hardest moment is not when you lose someone and tears come out of your eyes, but its when you lose someone and still you have to manage a smile!
Ankit Garg
Bartender

Joined: Aug 03, 2008
Messages: 5911

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


SCJP 6.0 98%, SCWCD 5 98%, Javaranch SCJP FAQ, SCWCD Links
The hardest moment is not when you lose someone and tears come out of your eyes, but its when you lose someone and still you have to manage a smile!
Panos Katergiathis
Greenhorn

Joined: Sep 23, 2009
Messages: 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
Messages: 5911

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...

SCJP 6.0 98%, SCWCD 5 98%, Javaranch SCJP FAQ, SCWCD Links
The hardest moment is not when you lose someone and tears come out of your eyes, but its when you lose someone and still you have to manage a smile!
Panos Katergiathis
Greenhorn

Joined: Sep 23, 2009
Messages: 3

I will try this very soon, and provide feedback.
Thank you for assisting.

Panos

 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Java in General
 
RSS feed
 
New topic
replay challenge

trailboss links:

permaculture
diatomaceous earth
Sepp Holzer
rocket mass heater
raising chickens
cast iron
lawn care