My last patch let us query the list of Instruments supported by a DSSISynthesizer. This patch implements the Synthesizer's loadInstrument method, so we can select non-default soft-synth patches. I'm checking it in.
Here are some more random sounds made after loading an alternate Instrument into Xsynth. http://spindazzle.org/green/pics/second.ogg AG 2005-10-07 Anthony Green <[EMAIL PROTECTED]> * gnu/javax/sound/midi/dssi/DSSISynthesizer.java (loadInstrument): Implement. (selectProgram_): New native method. * include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h: Rebuilt. * native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c (selectProgram_): New function. Index: gnu/javax/sound/midi/dssi/DSSISynthesizer.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/javax/sound/midi/dssi/DSSISynthesizer.java,v retrieving revision 1.3 diff -u -r1.3 DSSISynthesizer.java --- gnu/javax/sound/midi/dssi/DSSISynthesizer.java 7 Oct 2005 15:49:03 -0000 1.3 +++ gnu/javax/sound/midi/dssi/DSSISynthesizer.java 8 Oct 2005 03:49:22 -0000 @@ -239,6 +239,7 @@ static native String getProgramName_(long handle, int index); static native int getProgramBank_(long handle, int index); static native int getProgramProgram_(long handle, int index); + static native void selectProgram_(long handle, int bank, int program); /** * @author Anthony Green ([EMAIL PROTECTED]) @@ -575,13 +576,18 @@ return false; } - /* (non-Javadoc) - * @see javax.sound.midi.Synthesizer#loadInstrument(javax.sound.midi.Instrument) + /* @see javax.sound.midi.Synthesizer#loadInstrument(javax.sound.midi.Instrument) */ public boolean loadInstrument(Instrument instrument) { - // TODO Auto-generated method stub - return false; + // FIXME: perhaps this isn't quite right. It can probably + // be in any soundbank. + if (instrument.getSoundbank() != defaultSoundbank) + throw new IllegalArgumentException ("Synthesizer doesn't support this instrument's soundbank"); + + Patch patch = instrument.getPatch(); + selectProgram_(sohandle, patch.getBank(), patch.getProgram()); + return true; } /* (non-Javadoc) Index: include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h =================================================================== RCS file: /cvsroot/classpath/classpath/include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h,v retrieving revision 1.3 diff -u -r1.3 gnu_javax_sound_midi_dssi_DSSISynthesizer.h --- include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h 7 Oct 2005 15:49:02 -0000 1.3 +++ include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h 8 Oct 2005 03:49:27 -0000 @@ -20,6 +20,7 @@ JNIEXPORT jstring JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramName_1 (JNIEnv *env, jclass, jlong, jint); JNIEXPORT jint JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramBank_1 (JNIEnv *env, jclass, jlong, jint); JNIEXPORT jint JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramProgram_1 (JNIEnv *env, jclass, jlong, jint); +JNIEXPORT void JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_selectProgram_1 (JNIEnv *env, jclass, jlong, jint, jint); #ifdef __cplusplus } Index: native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c =================================================================== RCS file: /cvsroot/classpath/classpath/native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c,v retrieving revision 1.5 diff -u -r1.5 gnu_javax_sound_midi_dssi_DSSISynthesizer.c --- native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c 7 Oct 2005 15:49:02 -0000 1.5 +++ native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c 8 Oct 2005 03:49:37 -0000 @@ -103,7 +103,7 @@ memcpy (buffer, data->left_buffer, nframes * sizeof(LADSPA_Data)); buffer = jack_port_get_buffer(data->jack_right_output_port, nframes); memcpy (buffer, data->left_buffer, nframes * sizeof(LADSPA_Data)); - + return 0; } @@ -533,3 +533,13 @@ } +JNIEXPORT void JNICALL +Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_selectProgram_1 + (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)), + jlong handle, jint bank, jint program) +{ + dssi_data *data = JLONG_TO_PTR(dssi_data, handle); + + (data->desc->select_program)(data->plugin_handle, + (unsigned) bank, (unsigned) program); +} _______________________________________________ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches