[Audio-engine-dev] Possible bugs

Karl Helgason kalli at midverk.is
Thu Feb 7 03:56:42 PST 2008


Hi Andi,

I glad to hear that gervill-0.8-fix1.jar fixed those problems.

The reason volume did not work for you
is that the statements:
   sequencer = MidiSystem.getSequencer();
   synthesizer = MidiSystem.getSynthesizer();
returns different instance of Gervill Synthesizer.

This mean that volume change on for example synthesizer object
won't affect playback on the sequencer object.

In Gervill the midi volume 127 means that the signal is not affected.
And 64 means that signal is attenuated by12 dB, while midi volume 256
will amplify the signal by 12 dB. So by specifying 256 as maximum volume
you are overdriving the output.

regards,
Karl
________________________________________
Frá: audio-engine-dev-bounces at openjdk.java.net [audio-engine-dev-bounces at openjdk.java.net] Fyrir hönd Andreas Wenger [info at xenoage.com]
Sent: 7. febrúar 2008 08:56
Viðtakandi: audio-engine-dev at openjdk.java.net
Efni: [Audio-engine-dev]  Re: Possible bugs

Hi Karl,


gervill-0.8-fix1.jar fixed both problems.


Volume did not work, because I could only test Gervill with


 > sequencer = MidiSystem.getSequencer();
 > synthesizer = MidiSystem.getSynthesizer();


When using the now perfectly working

> sequencer = MidiSystem.getSequencer(false);
> synthesizer = MidiSystem.getSynthesizer();
> Transmitter seqTransmitter = sequencer.getTransmitter();
> seqTransmitter.setReceiver(synthesizer.getReceiver());


volume changes too (no idea why this is necessary, but it's the same
with old Java Sound. Perhaps anybody can tell me?
This is how I get the channels: MidiChannel[] channels =
synthesizer.getChannels();)


BTW, another thing I don't understand is the following (but same
thing in old Java Sound).
Many sites tell me, that volume control is between 0 and 127, see e.g.
http://www.musicmarkup.info/midi/control.html

In fact I get max volume with 255, min with 0.

Here is my complete setVolume method.

>   /**
>    * Sets the volume.
>    * @param volume  value between 0 (silent) and 1 (loud)
>    */
>   public void setVolume(float volume)
>   {
>     this.volume = volume;
>     MidiChannel[] channels = synthesizer.getChannels();
>
>     //TODO: should be 127 (some websites say this)
>     //but 255 is the real max volume!
>     int max = 255;
>
>     for (int i = 0; i < channels.length; i++)
>     {
>       channels[i].controlChange(7, (int) (volume * max));
>     }
>   }

Did I already mention that Gervill is just GREAT?!
Keep on your brilliant work! :-)


Andi




Karl Helgason schrieb:
> Hi,
>
> First:
>
> I can confirm this is a bug.
>
> Calling getReceiver before opening the synthesizer results in NullPointerException.
> This is not supposed to happen. Thanks for noticing this.
>
> Second:
>
> I tried our way to change volume, and it does work with Gervill.
> Please explain better how it failed.
>
> I uploaded updated version of gervill with this bug fixed:
> Please download "gervill-0.8-fix1.jar" from:
>    https://gervill.dev.java.net/servlets/ProjectDocumentList?folderID=0
> and let me know how this works.
>
> regards,
> Karl
>
> ________________________________________
> Frá: audio-engine-dev-bounces at openjdk.java.net [audio-engine-dev-bounces at openjdk.java.net] Fyrir h&#246;nd Andreas Wenger [info at xenoage.com]
> Sent: 6. febrúar 2008 17:08
> Viðtakandi: audio-engine-dev at openjdk.java.net
> Efni: [Audio-engine-dev]  Possible bugs
>
> Hi,
>
>
> I'm no experienced Java Sound user, so please forgive me if the following
> "bugs" are not caused by Gervill but my own program.
>
> I tried to integrate Gervill into my program Xenoage Player, which
> is a free MIDI player for MusicXML files, http://www.xenoage.com/player/
>
>
> First:
>
> This works:
>
>> sequencer = MidiSystem.getSequencer();
>> synthesizer = MidiSystem.getSynthesizer();
>>
> But this fails (works perfectly with old Java Sound):
>
>
>> sequencer = MidiSystem.getSequencer(false);
>> synthesizer = MidiSystem.getSynthesizer();
>> Transmitter seqTransmitter = sequencer.getTransmitter();
>> seqTransmitter.setReceiver(synthesizer.getReceiver());
>>
> with
>
>> java.lang.NullPointerException
>>     at com.sun.media.sound.SoftReceiver.<init>(Unknown Source)
>>     at com.sun.media.sound.SoftSynthesizer.getReceiver(Unknown Source)
>>     at com.xenoage.player.Player.<init>(Player.java:79)
>>
> Line 79 is "seqTransmitter.setReceiver(synthesizer.getReceiver());"
>
>
> Second:
>
> This is the way I change the playback volume (maybe this is bad code,
> but it was the only way it worked for me with old Java Sound):
>
>
>> MidiChannel[] channels = synthesizer.getChannels();
>> //...
>> for (int i = 0; i < channels.length; i++)
>> {
>>   channels[i].controlChange(7, (int) (volume * max));
>> }
>>
> This doesn't change the volume, while old Java Sound does.
>
>
> If it helps, code is available by SVN, see the website.
> If these are no bugs, please forgive me ;-)
>
> Bye,
>
>
> Andi
>
>
>
>
>
> _______________________________________________
> audio-engine-dev mailing list
> audio-engine-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/audio-engine-dev
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.19.20/1261 - Release Date: 5.2.2008 20:57
>
>

_______________________________________________
audio-engine-dev mailing list
audio-engine-dev at openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/audio-engine-dev

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.19.20/1261 - Release Date: 5.2.2008 20:57




More information about the audio-engine-dev mailing list