• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple Midi Channels Problem

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:


 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Protocol Webmaster please check your private messages for some administrative matter...
 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Panos Katertziadis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 Katertziadis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will try this very soon, and provide feedback.
Thank you for assisting.

Panos

 
reply
    Bookmark Topic Watch Topic
  • New Topic