From Joe.Darcy at Sun.COM Tue Jul 22 15:53:44 2008 From: Joe.Darcy at Sun.COM (Joe Darcy) Date: Tue, 22 Jul 2008 15:53:44 -0700 Subject: [Audio-engine-dev] Updating Gervill for OpenJDK 6 build 12 Message-ID: <488664F8.5000109@sun.com> Hello. With my OpenJDK 6 release manager hat on, I've been working to update the version of Gervill used to OpenJDK 6 to a newer version that passes the JCK tests, etc. and I'd like some review of my integration work. Before this exercise, I don't have any prior experience with sound code. A few comments, the copyright header in file SoftCubicResampler.java in the Gervill CVS master contains the typo "suabject" instead of "subject." From some casual examination of the code, it seems to use raw types throughout, that is "List" rather than "List", etc. It would be better to covert to using generics; I think IDEs have refactorings to help this now. There are some differences between the latest Gervill CVS from the project's site and the Gervill overlays in IcedTea 6. In particular, IcedTea has changes to SoftMixingMixer.java and SoftSynthesizer.java as well as some additional files, WaveExtensibleFileReader.java and WaveFloatFileWriter.java. I'd prefer to limit future merging work between the three code bases, Gervill CVS, OpenJDK 6, and IcedTea overlays, so in the context of updating Gervill for OpenJDK 6 b12, I think it would be good to resolve these remaining few differences. The test directories are the same in all three code bases, except I don't pick up a missing newline at the end of ./SoftCubicResampler/Interpolate.java. During the update I ran into some testing issues, both with the original Gervill integration in OpenJDK 6 b10 as well as the new code for b12. Specifically, the 9 regression tests javax/sound/midi/Gervill/SoftAudioSynthesizer/Open.java javax/sound/midi/Gervill/SoftSynthesizer/GetLatency.java javax/sound/midi/Gervill/SoftSynthesizer/GetReceiver.java javax/sound/midi/Gervill/SoftSynthesizer/GetReceiver2.java javax/sound/midi/Gervill/SoftSynthesizer/GetReceivers.java javax/sound/midi/Gervill/SoftSynthesizer/GetTransmitter.java javax/sound/midi/Gervill/SoftSynthesizer/GetTransmitters.java javax/sound/midi/Gervill/SoftSynthesizer/ImplicitOpenClose.java javax/sound/midi/Gervill/SoftSynthesizer/Open.java can fail, seemingly dependent on how one logs into the machine. What are the necessary and sufficient conditions for permissions to run these tests? When they occur, the failures I see look like: Windows ========= java.lang.IllegalArgumentException: No line matching interface SourceDataLine supporting format PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian is supported. at javax.sound.sampled.AudioSystem.getLine(AudioSystem.java:476) at javax.sound.sampled.AudioSystem.getSourceDataLine(AudioSystem.java:604) at com.sun.media.sound.SoftSynthesizer.open(SoftSynthesizer.java:762) at com.sun.media.sound.SoftSynthesizer.open(SoftSynthesizer.java:744) at Open.main(Open.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:96) at java.lang.Thread.run(Thread.java:636) Linux ====== STDERR: java: conf.c:3109: snd_config_update_free: Assertion `update->count > 0 && update->finfo' failed. TEST RESULT: Failed. Unexpected exit from test [exit code: 134] Solaris ======= java.lang.IllegalArgumentException: No line matching interface SourceDataLine supporting format PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian is supported. at javax.sound.sampled.AudioSystem.getLine(AudioSystem.java:476) at javax.sound.sampled.AudioSystem.getSourceDataLine(AudioSystem.java:604) at com.sun.media.sound.SoftSynthesizer.open(SoftSynthesizer.java:762) at com.sun.media.sound.SoftSynthesizer.open(SoftSynthesizer.java:744) at Open.main(Open.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:96) at java.lang.Thread.run(Thread.java:636) These failures occur with the essentially Gervill CVS files I'm using as well as the IcedTea versions. I've uploaded my webrev compared to the OpenJDK 6 b11 sources to http://dcstaff.invokedynamic.info/index.php?title=Image:darcy-6717691.tgz Below are the diffs of between Gervill CVS and my workspace and the recent IcedTea overlays and my workspace; I just loop over the Java files in the base directory, print out the file name, and then the result of diff-ing with the corresponding files in my workspace. Thanks, -Joe Latest Gervill CVS (July 21, 2008) vs my workspace: ======================================== AudioFileSoundbankReader.java AudioFloatConverter.java AudioFloatFormatConverter.java AudioFloatInputStream.java AudioSynthesizer.java AudioSynthesizerPropertyInfo.java DLSInfo.java DLSInstrument.java DLSModulator.java DLSRegion.java DLSSample.java DLSSampleLoop.java DLSSampleOptions.java DLSSoundbank.java DLSSoundbankReader.java EmergencySoundbank.java FFT.java InvalidDataException.java InvalidFormatException.java JARSoundbankReader.java ModelAbstractChannelMixer.java ModelAbstractOscillator.java ModelByteBuffer.java ModelByteBufferWavetable.java ModelChannelMixer.java ModelConnectionBlock.java ModelDestination.java ModelDirectedPlayer.java ModelDirector.java ModelIdentifier.java ModelInstrument.java ModelInstrumentComparator.java ModelMappedInstrument.java ModelOscillator.java ModelOscillatorStream.java ModelPatch.java ModelPerformer.java ModelSource.java ModelStandardDirector.java ModelStandardTransform.java ModelTransform.java ModelWavetable.java RIFFInvalidDataException.java RIFFInvalidFormatException.java RIFFReader.java RIFFWriter.java SF2GlobalRegion.java SF2Instrument.java SF2InstrumentRegion.java SF2Layer.java SF2LayerRegion.java SF2Modulator.java SF2Region.java SF2Sample.java SF2Soundbank.java SF2SoundbankReader.java SimpleInstrument.java SimpleSoundbank.java SoftAbstractResampler.java SoftAudioBuffer.java SoftAudioProcessor.java SoftAudioPusher.java SoftChannel.java SoftChannelProxy.java SoftChorus.java SoftControl.java SoftCubicResampler.java 8c8 < * particular file as suabject to the "Classpath" exception as provided --- > * particular file as subject to the "Classpath" exception as provided SoftEnvelopeGenerator.java SoftFilter.java SoftInstrument.java SoftJitterCorrector.java SoftLanczosResampler.java SoftLimiter.java SoftLinearResampler.java SoftLinearResampler2.java SoftLowFrequencyOscillator.java SoftMainMixer.java SoftMidiAudioFileReader.java SoftMixingClip.java SoftMixingDataLine.java SoftMixingMainMixer.java SoftMixingMixer.java SoftMixingMixerProvider.java SoftMixingSourceDataLine.java SoftPerformer.java SoftPointResampler.java SoftProcess.java SoftProvider.java SoftReceiver.java SoftResampler.java SoftResamplerStreamer.java SoftReverb.java SoftShortMessage.java SoftSincResampler.java SoftSynthesizer.java SoftTuning.java SoftVoice.java IcedTea 6 58510fd936ff overlays vs my workspace ====================================== AudioFileSoundbankReader.java AudioFloatConverter.java AudioFloatFormatConverter.java AudioFloatInputStream.java AudioSynthesizer.java AudioSynthesizerPropertyInfo.java DLSInfo.java DLSInstrument.java DLSModulator.java DLSRegion.java DLSSample.java DLSSampleLoop.java DLSSampleOptions.java DLSSoundbank.java DLSSoundbankReader.java 50,51d49 < } catch(IOException ioe) { < return null; EmergencySoundbank.java FFT.java InvalidDataException.java InvalidFormatException.java JARSoundbankReader.java ModelAbstractChannelMixer.java ModelAbstractOscillator.java ModelByteBuffer.java ModelByteBufferWavetable.java ModelChannelMixer.java ModelConnectionBlock.java ModelDestination.java ModelDirectedPlayer.java ModelDirector.java ModelIdentifier.java ModelInstrument.java ModelInstrumentComparator.java ModelMappedInstrument.java ModelOscillator.java ModelOscillatorStream.java ModelPatch.java ModelPerformer.java ModelSource.java ModelStandardDirector.java ModelStandardTransform.java ModelTransform.java ModelWavetable.java RIFFInvalidDataException.java RIFFInvalidFormatException.java RIFFReader.java RIFFWriter.java SF2GlobalRegion.java SF2Instrument.java SF2InstrumentRegion.java SF2Layer.java SF2LayerRegion.java SF2Modulator.java SF2Region.java SF2Sample.java SF2Soundbank.java SF2SoundbankReader.java 49,50d48 < } catch(IOException ioe) { < return null; SimpleInstrument.java SimpleSoundbank.java SoftAbstractResampler.java SoftAudioBuffer.java SoftAudioProcessor.java SoftAudioPusher.java SoftChannel.java 1197,1199c1197 < // Should only return lower 7 bits, < // even when controller is "boosted" higher. < return this.controller[controller] & 127; --- > return this.controller[controller]; SoftChannelProxy.java SoftChorus.java SoftControl.java SoftCubicResampler.java 8c8 < * particular file as suabject to the "Classpath" exception as provided --- > * particular file as subject to the "Classpath" exception as provided SoftEnvelopeGenerator.java SoftFilter.java SoftInstrument.java SoftJitterCorrector.java SoftLanczosResampler.java SoftLimiter.java SoftLinearResampler.java SoftLinearResampler2.java SoftLowFrequencyOscillator.java SoftMainMixer.java SoftMidiAudioFileReader.java SoftMixingClip.java SoftMixingDataLine.java SoftMixingMainMixer.java SoftMixingMixer.java 357,359d356 < DataLine.Info info = new DataLine.Info( < SourceDataLine.class, format); < 368,369c365,413 < line = (SourceDataLine) defaultmixer.getLine(info); < else --- > { > // Search for suitable line > > DataLine.Info idealinfo = null; > AudioFormat idealformat = null; > > Line.Info[] lineinfos = defaultmixer.getSourceLineInfo(); > idealFound: > for (int i = 0; i < lineinfos.length; i++) { > if(lineinfos[i].getLineClass() == SourceDataLine.class) > { > DataLine.Info info = (DataLine.Info)lineinfos[i]; > AudioFormat[] formats = info.getFormats(); > for (int j = 0; j < formats.length; j++) { > AudioFormat format = formats[j]; > if(format.getChannels() == 2 || > format.getChannels() == AudioSystem.NOT_SPECIFIED) > if(format.getEncoding().equals(Encoding.PCM_SIGNED) || > format.getEncoding().equals(Encoding.PCM_UNSIGNED)) > if(format.getSampleRate() == AudioSystem.NOT_SPECIFIED || > format.getSampleRate() == 48000.0) > if(format.getSampleSizeInBits() == AudioSystem.NOT_SPECIFIED || > format.getSampleSizeInBits() == 16) > { > idealinfo = info; > int ideal_channels = format.getChannels(); > boolean ideal_signed = format.getEncoding().equals(Encoding.PCM_SIGNED); > float ideal_rate = format.getSampleRate(); > boolean ideal_endian = format.isBigEndian(); > int ideal_bits = format.getSampleSizeInBits(); > if(ideal_bits == AudioSystem.NOT_SPECIFIED) ideal_bits = 16; > if(ideal_channels == AudioSystem.NOT_SPECIFIED) ideal_channels = 2; > if(ideal_rate == AudioSystem.NOT_SPECIFIED) ideal_rate = 48000; > idealformat = new AudioFormat(ideal_rate, ideal_bits, > ideal_channels, ideal_signed, ideal_endian); > break idealFound; > } > } > } > } > > if(idealformat != null) > { > format = idealformat; > line = (SourceDataLine) defaultmixer.getLine(idealinfo); > } > } > > if(line == null) SoftMixingMixerProvider.java SoftMixingSourceDataLine.java SoftPerformer.java SoftPointResampler.java SoftProcess.java SoftProvider.java SoftReceiver.java SoftResampler.java SoftResamplerStreamer.java SoftReverb.java SoftShortMessage.java SoftSincResampler.java SoftSynthesizer.java 540a541,546 > File userhome = null; > File emg_soundbank_file = null; > > /* > * Try to load saved generated soundbank > */ 541a548,563 > userhome = new File(System.getProperty("user.home"), > ".gervill"); > emg_soundbank_file = new File(userhome, "soundbank-emg.sf2"); > Soundbank sbk = MidiSystem.getSoundbank(emg_soundbank_file); > defaultSoundBank = sbk; > return defaultSoundBank; > } catch (AccessControlException e) { > } catch (Exception e) { > //e.printStackTrace(); > } > > try { > > /* > * Generate emergency soundbank > */ 542a565,574 > > /* > * Save generated soundbank to disk for faster future use. > */ > if(defaultSoundBank != null) > { > if(!userhome.exists()) userhome.mkdirs(); > if(!emg_soundbank_file.exists()) > ((SF2Soundbank)defaultSoundBank).save(emg_soundbank_file); > } 594,596d625 < if (soundbank == null || !isSoundbankSupported(soundbank)) < throw new IllegalArgumentException("Unsupported soundbank: " + soundbank); < 621,623d649 < if (soundbank == null || !isSoundbankSupported(soundbank)) < throw new IllegalArgumentException("Unsupported soundbank: " + soundbank); < SoftTuning.java SoftVoice.java WaveExtensibleFileReader.java diff: /net/hest.sfbay/w/darcy/ws/6-open.new/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java: No such file or directory WaveFloatFileReader.java 74a75 > long framerate = 1; 89c90 < /* framerate = */chunk.readUnsignedInt(); --- > framerate = chunk.readUnsignedInt(); 106c107 < framesize, samplerate, false); --- > framesize, framerate, false); WaveFloatFileWriter.java diff: /net/hest.sfbay/w/darcy/ws/6-open.new/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java: No such file or directory From kalli at midverk.is Thu Jul 24 19:02:34 2008 From: kalli at midverk.is (Karl Helgason) Date: Fri, 25 Jul 2008 02:02:34 +0000 Subject: [Audio-engine-dev] New Gervill imported (Was: OpenJDK 6 b10 source posted) In-Reply-To: <1212963828.3111.23.camel@dijkstra.wildebeest.org> References: <36EC82E93EB0AD40A4301DAD654323868CA4FB2AE1@mail.midverk.is> <1212571525.3172.11.camel@dijkstra.wildebeest.org>, <1212963828.3111.23.camel@dijkstra.wildebeest.org> Message-ID: <36EC82E93EB0AD40A4301DAD65432386B243F376D4@mail.midverk.is> Hi Mark, Control rate can be fetched from the synthesizer using the AudioSynthesizer interface. AudioSynthesizer.getPropertyInfo() And if you want to use another control rate you'll have to open the synthesizer with the open(SourceDataLine line, Map info) using different control rate value in the info parameter. But it could be a good idea that getPropertyInfo() would return current values when the synthesizer is open and default ones when it is closed. I changed these methods in the SoftChannel noteOn noteOff setPolyPressure setChannelPressure controlChange programChange(program) programChange(bank, program) setPitchBend So they won't accept out of range values (e.g. only 7 or 14 bit values). I didn't like your idea of masking the getController output, and it also didn't handle when we used negative values in the controlChange. By restricting the input values we make the MidiChannel object more predictable and getController will then always return true value not clipped one. I am not sure we should hide the IOException in SF2SoundbankReader and DLSSoundbankReader. This is not done in AudioFileReader classes from Sun. For example in com.sun.media.sound.WaveFileReader cheers, Karl ________________________________________ Fr?: Mark Wielaard [mark at klomp.org] Sent: 8. j?n? 2008 22:23 Vi?takandi: Karl Helgason Afrit: audio-engine-dev at openjdk.java.net; distro-pkg-dev at openjdk.java.net Efni: New Gervill imported (Was: OpenJDK 6 b10 source posted) Hi Karl, On Wed, 2008-06-04 at 11:25 +0200, Mark Wielaard wrote: > On Wed, 2008-06-04 at 01:09 +0000, Karl Helgason wrote: > Thanks for checking. These are all in the icedtea gervill overlay also. > I'll make sure to upgrade to the latest CVS version in which I see you > fixed some of the other issues I reported. > > > The code was also slightly reformatted: > > a) lines "* @version %I%, %E%" was removed (such lines was removed from all JDK > > sources); > > b) line indention (to make lines no longer than 80 symbols); > > c) tabs to spaces conversion; > > > > I will look into to reformat newest Gervill CVS code the same way. > > That would be great. Since 0.9 there have been lots of changes and fixes > (which is why icedtea tracks your CVS tree and didn't use the old 0.9 > code). Would it be a good idea to do a new version upgrade after syncing > the sources and reformatting to celebrate the inclusion? Thanks a lot for you fixes and the reformatting. I imported the new Gervill from CVS in two parts. First everything up to June 1st. Second the reformatting itself. That way it should be easy to follow what changed. 2008-08-08 Mark Wielaard * overlays/openjdk/jdk/src/share/classes/com/sun/media/sound: Import Gervill fixes from CVS. See CHANGES.txt. * overlays/openjdk/jdk/test/com/sun/media/sound: Likewise. - Cleanup: Make inner classes static AudioFloatFormatConverter.AudioFloatFormatConverterInputStream AudioFloatFormatConverter.AudioFloatInputStreamChannelMixer AudioFloatFormatConverter.AudioFloatInputStreamResampler SimpleInstrument.SimpleInstrumentPart SoftChorus.VariableDelay SoftChorus.LFODelay SoftMixingDataLine.AudioFloatInputStreamResampler SoftMixingSourceDataLine.NonBlockingFloatInputStream SoftReverb.AllPass SoftReverb.Comb SoftReverb.Delay - Cleanup: Remove unused fields in: SoftSincResampler.din, SoftLanczosResampler.din, SoftMainMixer.finetuning, SoftMainMixer.coarsetuning SoftJitterCorrector.JitterStream.nullbuff, SoftAbstractResampler.ModelAbstractResampler.loopread SoftAbstractResampler.ModelAbstractResampler.streammarked - Cleanup: Remove dead code from FFT. - Cleanup: Make constant fields in SoftFilter final. - Cleanup: Let SoftSynthesizer.info be final. - Cleanup: Let SoftProvider.info be final. - Fix: Unnecessary call to sourceDataLine.drain() in SoftSynthesizer causes random hangs in SoftSynthesizer.open jtreg test. This happens when the synthesizer is opened and right after closed. This will not happen if there is a delay between open and close call. - Fix: ModelByteBufferAudioFileSoundbankReader, SoftAudioPusher, SoftJitterCorrector don't ignore stream.read return value. - Fix: NullPointerException in SoftSynthesizer.unloadInstrument if instrument = null - Fix: SoftJitterCorrector.getSoundbank(URL) may fail to close stream. - Fix: Futile attempts to guard buffers variable in SoftJitterCorrector. - Fix: RiffReader/SF2SoundbankReader/DLSSoundbank should use readfully instead of read when reading from stream. JTreg tests where created to test for this. I like these cleanups. Your fix for the jtreg resources was nicer than mine, so I dropped the icedtea one. I did take your change to the tests needing a samplerate and controlrate argument to init the SoftLimiter to just pass the constant values 44100 and 147. I also made the SoftSynthesizer.getControlRate() protected again. I can kind of understand using these constants in the tests. Although I find getting them from the synthesizer nicer. Is there a reason the control rate is always hardcoded to 147? There actually doesn't seem to be any way to change it since the property info always sets it explicitly. With this there are only a few minor differences left between gervill CVS and the icedtea overlay. I have attached the diff. 2008-06-08 Mark Wielaard * overlays/openjdk/jdk/src/share/classes/com/sun/media/sound: Import Gervill CVS source reformatting. For the interested I have attached the current diff between the gervil/cvs/icedtea/overlay version and what is in openjdk6-b10. (Note that line endings are different, openjdk6 uses CRLF, which is disregarded when creating the diff.) Cheers, Mark