• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Java, DLSSynth, DefaultOutput, Midi event playing.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Java, DLSSynth, DefaultOutput, Midi event playing.


  • Subject: Re: Java, DLSSynth, DefaultOutput, Midi event playing.
  • From: Kurt Revis <email@hidden>
  • Date: Mon, 2 Sep 2002 00:38:16 -0700

On Sunday, September 1, 2002, at 11:32 PM, email@hidden wrote:

Hi I think the following code should make some sort of noise when run.
Any suggestions on why it doesn't?

A few things...

// Connect the devices up
graph.connectNodeInput(synthNode, 1, outputNode, 0);

I needed to change the 1 to 0 to get this to work. Which makes sense: the 0th output of the synth goes into the 0th input of the output unit.

// send the event to the synth
// use the MusicDeviceMIDIEvent() call.
MusicDevice synthUnit = (MusicDevice)
graph.getNodeInfo_AudioUnit(synthNode);
ExtendedNoteParams noteParameters = new
ExtendedNoteParams(new float[] {0f, 60f, 127f, 0f});
synthUnit.startNote(10, 0, 0, noteParameters);
synthUnit.stopNote(10, 0, 0);

I couldn't make any sense out of the extended note parameter stuff in Java--I can't find any docs which describe the 4 parameters you are giving it. (I can guess about the 60 and 127, but I don't know what the 0s are for.) Perhaps someone else can help with that. I just changed it to do a simple MIDI note, like this:

synthUnit.sendMIDIEvent(0x90, 60, 127, 0); // note-on
synthUnit.sendMIDIEvent(0x80, 60, 0, 10000); // note-off

You definitely want the note-off (or stopNote) to take place after a delay. Your code above will stop the note at the same time that it is started, so you may not hear it at all.

Finally, if you are running this as a self-contained tool, it will exit before you hear much of the the note. So I added this code to sleep for 5 seconds so the note has time to sound:

try {
Thread.sleep(5000);
} catch (Exception exception) {
// ignore
}

With these changes, I hear a note just fine.

--
Kurt Revis
email@hidden
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Java, DLSSynth, DefaultOutput, Midi event playing.
      • From: Bill Stewart <email@hidden>
References: 
 >Java, DLSSynth, DefaultOutput, Midi event playing. (From: email@hidden)

  • Prev by Date: Java, DLSSynth, DefaultOutput, Midi event playing.
  • Next by Date: Re: Playing lots of tiny sounds with different formats?
  • Previous by thread: Java, DLSSynth, DefaultOutput, Midi event playing.
  • Next by thread: Re: Java, DLSSynth, DefaultOutput, Midi event playing.
  • Index(es):
    • Date
    • Thread