diff options
author | RubbaBoy <[email protected]> | 2020-07-06 02:33:28 -0400 |
---|---|---|
committer | Phil Burk <[email protected]> | 2020-10-30 11:19:34 -0700 |
commit | 46888fae6eb7b1dd386f7af7d101ead99ae61981 (patch) | |
tree | 8969bbfd68d2fb5c0d8b86da49ec2eca230a72ab | |
parent | c51e92e813dd481603de078f0778e1f75db2ab05 (diff) |
Restructured project, added gradle, JUnit, logger, and more
Added Gradle (and removed ant), modernized testing via the JUnit framework, moved standalone examples from the tests directory to a separate module, removed sparsely used Java logger and replaced it with SLF4J. More work could be done, however this is a great start to greatly improving the health of the codebase.
-rw-r--r-- | .classpath | 9 | ||||
-rw-r--r-- | .gitignore | 14 | ||||
-rw-r--r-- | .project | 17 | ||||
-rw-r--r-- | DEVELOPING.md | 44 | ||||
-rw-r--r-- | README.txt | 1 | ||||
-rw-r--r-- | android/README.md | 2 | ||||
-rw-r--r-- | android/com/jsyn/devices/android/AndroidAudioForJSyn.java | 4 | ||||
-rw-r--r-- | build.gradle | 60 | ||||
-rw-r--r-- | build.xml | 66 | ||||
-rw-r--r-- | examples/build.gradle | 14 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/AudioPassThrough.java (renamed from tests/com/jsyn/examples/AudioPassThrough.java) | 23 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/ChebyshevSong.java (renamed from tests/com/jsyn/examples/ChebyshevSong.java) | 16 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/CircuitTester.java (renamed from tests/com/jsyn/examples/CircuitTester.java) | 4 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/CustomCubeUnit.java (renamed from tests/com/jsyn/examples/CustomCubeUnit.java) | 8 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/DualOscilloscope.java (renamed from tests/com/jsyn/examples/DualOscilloscope.java) | 9 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/EditEnvelope1.java (renamed from tests/com/jsyn/examples/EditEnvelope1.java) | 8 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/FFTPassthrough.java (renamed from tests/com/jsyn/examples/FFTPassthrough.java) | 17 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/GoogleWaveOscillator.java (renamed from tests/com/jsyn/examples/GoogleWaveOscillator.java) | 9 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/HearDAHDSR.java (renamed from tests/com/jsyn/examples/HearDAHDSR.java) | 16 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/HearMoogFilter.java (renamed from tests/com/jsyn/examples/HearMoogFilter.java) | 3 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/HearSinePM.java (renamed from tests/com/jsyn/examples/HearSinePM.java) | 3 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/HearSpectralFilter.java (renamed from tests/com/jsyn/examples/HearSpectralFilter.java) | 19 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/ListAudioDevices.java (renamed from tests/com/jsyn/examples/ListAudioDevices.java) | 14 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/LongEcho.java (renamed from tests/com/jsyn/examples/LongEcho.java) | 7 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/MonoPassThrough.java (renamed from tests/com/jsyn/examples/MonoPassThrough.java) | 0 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/NotesToTone.java (renamed from tests/com/jsyn/examples/NotesToTone.java) | 15 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlayChords.java (renamed from tests/com/jsyn/examples/PlayChords.java) | 16 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlayCustomUnit.java (renamed from tests/com/jsyn/examples/PlayCustomUnit.java) | 0 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlayFunction.java (renamed from tests/com/jsyn/examples/PlayFunction.java) | 49 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlayGrains.java (renamed from tests/com/jsyn/examples/PlayGrains.java) | 17 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlayMIDI.java (renamed from tests/com/jsyn/examples/PlayMIDI.java) | 30 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlayNotes.java (renamed from tests/com/jsyn/examples/PlayNotes.java) | 31 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlayPartials.java (renamed from tests/com/jsyn/examples/PlayPartials.java) | 17 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlaySample.java (renamed from tests/com/jsyn/examples/PlaySample.java) | 27 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlaySampleCrossfade.java (renamed from tests/com/jsyn/examples/PlaySampleCrossfade.java) | 25 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlaySampleWaveShaper.java (renamed from tests/com/jsyn/examples/PlaySampleWaveShaper.java) | 26 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlaySegmentedEnvelope.java (renamed from tests/com/jsyn/examples/PlaySegmentedEnvelope.java) | 13 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlaySegmentedEnvelopeCallback.java (renamed from tests/com/jsyn/examples/PlaySegmentedEnvelopeCallback.java) | 17 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlaySequence.java (renamed from tests/com/jsyn/examples/PlaySequence.java) | 0 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/PlayTone.java (renamed from tests/com/jsyn/examples/PlayTone.java) | 37 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/RecordSineSweep.java (renamed from tests/com/jsyn/examples/RecordSineSweep.java) | 15 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/SampleHoldNoteBlaster.java (renamed from tests/com/jsyn/examples/SampleHoldNoteBlaster.java) | 0 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/SawFaders.java (renamed from tests/com/jsyn/examples/SawFaders.java) | 9 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/SeeGoogleWave.java (renamed from tests/com/jsyn/examples/SeeGoogleWave.java) | 9 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/SeeOscillators.java (renamed from tests/com/jsyn/examples/SeeOscillators.java) | 3 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/ShowWaves.java (renamed from tests/com/jsyn/examples/ShowWaves.java) | 9 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/SwarmOfOscillators.java (renamed from tests/com/jsyn/examples/SwarmOfOscillators.java) | 0 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/UseMidiKeyboard.java (renamed from tests/com/jsyn/examples/UseMidiKeyboard.java) | 8 | ||||
-rw-r--r-- | examples/src/main/java/com/jsyn/examples/WindCircuit.java (renamed from tests/com/jsyn/examples/WindCircuit.java) | 0 | ||||
-rw-r--r-- | examples/src/main/resources/log4j.xml | 15 | ||||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.jar | bin | 0 -> 55616 bytes | |||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.properties | 5 | ||||
-rw-r--r-- | gradlew | 188 | ||||
-rw-r--r-- | gradlew.bat | 100 | ||||
-rw-r--r-- | settings.gradle | 2 | ||||
-rw-r--r-- | src/main/java/com/jsyn/JSyn.java (renamed from src/com/jsyn/JSyn.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/Synthesizer.java (renamed from src/com/jsyn/Synthesizer.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/apps/AboutJSyn.java (renamed from src/com/jsyn/apps/AboutJSyn.java) | 8 | ||||
-rw-r--r-- | src/main/java/com/jsyn/apps/InstrumentTester.java (renamed from src/com/jsyn/apps/InstrumentTester.java) | 11 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/AudioSample.java (renamed from src/com/jsyn/data/AudioSample.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/DoubleTable.java (renamed from src/com/jsyn/data/DoubleTable.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/FloatSample.java (renamed from src/com/jsyn/data/FloatSample.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/Function.java (renamed from src/com/jsyn/data/Function.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/HammingWindow.java (renamed from src/com/jsyn/data/HammingWindow.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/HannWindow.java (renamed from src/com/jsyn/data/HannWindow.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/SampleMarker.java (renamed from src/com/jsyn/data/SampleMarker.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/SegmentedEnvelope.java (renamed from src/com/jsyn/data/SegmentedEnvelope.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/SequentialData.java (renamed from src/com/jsyn/data/SequentialData.java) | 1 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/SequentialDataCommon.java (renamed from src/com/jsyn/data/SequentialDataCommon.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/ShortSample.java (renamed from src/com/jsyn/data/ShortSample.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/SpectralWindow.java (renamed from src/com/jsyn/data/SpectralWindow.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/SpectralWindowFactory.java (renamed from src/com/jsyn/data/SpectralWindowFactory.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/data/Spectrum.java (renamed from src/com/jsyn/data/Spectrum.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/devices/AudioDeviceFactory.java (renamed from src/com/jsyn/devices/AudioDeviceFactory.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/devices/AudioDeviceInputStream.java (renamed from src/com/jsyn/devices/AudioDeviceInputStream.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/devices/AudioDeviceManager.java (renamed from src/com/jsyn/devices/AudioDeviceManager.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/devices/AudioDeviceOutputStream.java (renamed from src/com/jsyn/devices/AudioDeviceOutputStream.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/devices/javasound/JavaSoundAudioDevice.java (renamed from src/com/jsyn/devices/javasound/JavaSoundAudioDevice.java) | 27 | ||||
-rw-r--r-- | src/main/java/com/jsyn/devices/javasound/MidiDeviceTools.java (renamed from src/com/jsyn/devices/javasound/MidiDeviceTools.java) | 16 | ||||
-rw-r--r-- | src/main/java/com/jsyn/devices/jportaudio/JPortAudioDevice.java (renamed from src/com/jsyn/devices/jportaudio/JPortAudioDevice.java) | 15 | ||||
-rw-r--r-- | src/main/java/com/jsyn/engine/LoadAnalyzer.java (renamed from src/com/jsyn/engine/LoadAnalyzer.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/engine/MultiTable.java (renamed from src/com/jsyn/engine/MultiTable.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/engine/SynthesisEngine.java (renamed from src/com/jsyn/engine/SynthesisEngine.java) | 42 | ||||
-rw-r--r-- | src/main/java/com/jsyn/exceptions/ChannelMismatchException.java (renamed from src/com/jsyn/exceptions/ChannelMismatchException.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/instruments/DrumWoodFM.java (renamed from src/com/jsyn/instruments/DrumWoodFM.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/instruments/DualOscillatorSynthVoice.java (renamed from src/com/jsyn/instruments/DualOscillatorSynthVoice.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/instruments/JSynInstrumentLibrary.java (renamed from src/com/jsyn/instruments/JSynInstrumentLibrary.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/instruments/NoiseHit.java (renamed from src/com/jsyn/instruments/NoiseHit.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/instruments/SubtractiveSynthVoice.java (renamed from src/com/jsyn/instruments/SubtractiveSynthVoice.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/instruments/WaveShapingVoice.java (renamed from src/com/jsyn/instruments/WaveShapingVoice.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/io/AudioFifo.java (renamed from src/com/jsyn/io/AudioFifo.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/io/AudioInputStream.java (renamed from src/com/jsyn/io/AudioInputStream.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/io/AudioOutputStream.java (renamed from src/com/jsyn/io/AudioOutputStream.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/midi/MessageParser.java (renamed from src/com/jsyn/midi/MessageParser.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/midi/MidiConstants.java (renamed from src/com/jsyn/midi/MidiConstants.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/midi/MidiSynthesizer.java (renamed from src/com/jsyn/midi/MidiSynthesizer.java) | 9 | ||||
-rw-r--r-- | src/main/java/com/jsyn/package.html (renamed from src/com/jsyn/package.html) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/ConnectableInput.java (renamed from src/com/jsyn/ports/ConnectableInput.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/ConnectableOutput.java (renamed from src/com/jsyn/ports/ConnectableOutput.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/GettablePort.java (renamed from src/com/jsyn/ports/GettablePort.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/InputMixingBlockPart.java (renamed from src/com/jsyn/ports/InputMixingBlockPart.java) | 2 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/PortBlockPart.java (renamed from src/com/jsyn/ports/PortBlockPart.java) | 11 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/QueueDataCommand.java (renamed from src/com/jsyn/ports/QueueDataCommand.java) | 6 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/QueueDataEvent.java (renamed from src/com/jsyn/ports/QueueDataEvent.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/SequentialDataCrossfade.java (renamed from src/com/jsyn/ports/SequentialDataCrossfade.java) | 16 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/SettablePort.java (renamed from src/com/jsyn/ports/SettablePort.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/UnitBlockPort.java (renamed from src/com/jsyn/ports/UnitBlockPort.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/UnitDataQueueCallback.java (renamed from src/com/jsyn/ports/UnitDataQueueCallback.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/UnitDataQueuePort.java (renamed from src/com/jsyn/ports/UnitDataQueuePort.java) | 4 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/UnitFunctionPort.java (renamed from src/com/jsyn/ports/UnitFunctionPort.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/UnitGatePort.java (renamed from src/com/jsyn/ports/UnitGatePort.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/UnitInputPort.java (renamed from src/com/jsyn/ports/UnitInputPort.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/UnitOutputPort.java (renamed from src/com/jsyn/ports/UnitOutputPort.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/UnitPort.java (renamed from src/com/jsyn/ports/UnitPort.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/UnitSpectralInputPort.java (renamed from src/com/jsyn/ports/UnitSpectralInputPort.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/UnitSpectralOutputPort.java (renamed from src/com/jsyn/ports/UnitSpectralOutputPort.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/UnitVariablePort.java (renamed from src/com/jsyn/ports/UnitVariablePort.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/ports/package.html (renamed from src/com/jsyn/ports/package.html) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/AudioScope.java (renamed from src/com/jsyn/scope/AudioScope.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/AudioScopeModel.java (renamed from src/com/jsyn/scope/AudioScopeModel.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/AudioScopeProbe.java (renamed from src/com/jsyn/scope/AudioScopeProbe.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/DefaultWaveTraceModel.java (renamed from src/com/jsyn/scope/DefaultWaveTraceModel.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/MultiChannelScopeProbeUnit.java (renamed from src/com/jsyn/scope/MultiChannelScopeProbeUnit.java) | 8 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/TriggerModel.java (renamed from src/com/jsyn/scope/TriggerModel.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/WaveTraceModel.java (renamed from src/com/jsyn/scope/WaveTraceModel.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/swing/AudioScopeProbeView.java (renamed from src/com/jsyn/scope/swing/AudioScopeProbeView.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/swing/AudioScopeView.java (renamed from src/com/jsyn/scope/swing/AudioScopeView.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/swing/MultipleWaveDisplay.java (renamed from src/com/jsyn/scope/swing/MultipleWaveDisplay.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/swing/ScopeControlPanel.java (renamed from src/com/jsyn/scope/swing/ScopeControlPanel.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/swing/ScopeProbePanel.java (renamed from src/com/jsyn/scope/swing/ScopeProbePanel.java) | 11 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/swing/ScopeTriggerPanel.java (renamed from src/com/jsyn/scope/swing/ScopeTriggerPanel.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/scope/swing/WaveTraceView.java (renamed from src/com/jsyn/scope/swing/WaveTraceView.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/ASCIIMusicKeyboard.java (renamed from src/com/jsyn/swing/ASCIIMusicKeyboard.java) | 10 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/DoubleBoundedRangeModel.java (renamed from src/com/jsyn/swing/DoubleBoundedRangeModel.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/DoubleBoundedRangeSlider.java (renamed from src/com/jsyn/swing/DoubleBoundedRangeSlider.java) | 12 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/DoubleBoundedTextField.java (renamed from src/com/jsyn/swing/DoubleBoundedTextField.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/EnvelopeEditorBox.java (renamed from src/com/jsyn/swing/EnvelopeEditorBox.java) | 26 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/EnvelopeEditorPanel.java (renamed from src/com/jsyn/swing/EnvelopeEditorPanel.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/EnvelopePoints.java (renamed from src/com/jsyn/swing/EnvelopePoints.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/ExponentialRangeModel.java (renamed from src/com/jsyn/swing/ExponentialRangeModel.java) | 39 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/InstrumentBrowser.java (renamed from src/com/jsyn/swing/InstrumentBrowser.java) | 10 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/JAppletFrame.java (renamed from src/com/jsyn/swing/JAppletFrame.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/PortBoundedRangeModel.java (renamed from src/com/jsyn/swing/PortBoundedRangeModel.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/PortControllerFactory.java (renamed from src/com/jsyn/swing/PortControllerFactory.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/PortModelFactory.java (renamed from src/com/jsyn/swing/PortModelFactory.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/PresetSelectionListener.java (renamed from src/com/jsyn/swing/PresetSelectionListener.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/RotaryController.java (renamed from src/com/jsyn/swing/RotaryController.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/RotaryTextController.java (renamed from src/com/jsyn/swing/RotaryTextController.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/SoundTweaker.java (renamed from src/com/jsyn/swing/SoundTweaker.java) | 6 | ||||
-rw-r--r-- | src/main/java/com/jsyn/swing/XYController.java (renamed from src/com/jsyn/swing/XYController.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Add.java (renamed from src/com/jsyn/unitgen/Add.java) | 16 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/AsymptoticRamp.java (renamed from src/com/jsyn/unitgen/AsymptoticRamp.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/BrownNoise.java (renamed from src/com/jsyn/unitgen/BrownNoise.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/ChannelIn.java (renamed from src/com/jsyn/unitgen/ChannelIn.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/ChannelOut.java (renamed from src/com/jsyn/unitgen/ChannelOut.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Circuit.java (renamed from src/com/jsyn/unitgen/Circuit.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Compare.java (renamed from src/com/jsyn/unitgen/Compare.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/ContinuousRamp.java (renamed from src/com/jsyn/unitgen/ContinuousRamp.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/CrossFade.java (renamed from src/com/jsyn/unitgen/CrossFade.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Delay.java (renamed from src/com/jsyn/unitgen/Delay.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Divide.java (renamed from src/com/jsyn/unitgen/Divide.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/DualInTwoOut.java (renamed from src/com/jsyn/unitgen/DualInTwoOut.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/EdgeDetector.java (renamed from src/com/jsyn/unitgen/EdgeDetector.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/EnvelopeAttackDecay.java (renamed from src/com/jsyn/unitgen/EnvelopeAttackDecay.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/EnvelopeDAHDSR.java (renamed from src/com/jsyn/unitgen/EnvelopeDAHDSR.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/ExponentialRamp.java (renamed from src/com/jsyn/unitgen/ExponentialRamp.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FFT.java (renamed from src/com/jsyn/unitgen/FFT.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FFTBase.java (renamed from src/com/jsyn/unitgen/FFTBase.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterAllPass.java (renamed from src/com/jsyn/unitgen/FilterAllPass.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterBandPass.java (renamed from src/com/jsyn/unitgen/FilterBandPass.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterBandStop.java (renamed from src/com/jsyn/unitgen/FilterBandStop.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterBiquad.java (renamed from src/com/jsyn/unitgen/FilterBiquad.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterBiquadCommon.java (renamed from src/com/jsyn/unitgen/FilterBiquadCommon.java) | 8 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterBiquadShelf.java (renamed from src/com/jsyn/unitgen/FilterBiquadShelf.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterFourPoles.java (renamed from src/com/jsyn/unitgen/FilterFourPoles.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterHighPass.java (renamed from src/com/jsyn/unitgen/FilterHighPass.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterHighShelf.java (renamed from src/com/jsyn/unitgen/FilterHighShelf.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterLowPass.java (renamed from src/com/jsyn/unitgen/FilterLowPass.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterLowShelf.java (renamed from src/com/jsyn/unitgen/FilterLowShelf.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterOnePole.java (renamed from src/com/jsyn/unitgen/FilterOnePole.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterOnePoleOneZero.java (renamed from src/com/jsyn/unitgen/FilterOnePoleOneZero.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterOneZero.java (renamed from src/com/jsyn/unitgen/FilterOneZero.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterPeakingEQ.java (renamed from src/com/jsyn/unitgen/FilterPeakingEQ.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterStateVariable.java (renamed from src/com/jsyn/unitgen/FilterStateVariable.java) | 4 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterTwoPoles.java (renamed from src/com/jsyn/unitgen/FilterTwoPoles.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FilterTwoPolesTwoZeros.java (renamed from src/com/jsyn/unitgen/FilterTwoPolesTwoZeros.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FixedRateMonoReader.java (renamed from src/com/jsyn/unitgen/FixedRateMonoReader.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FixedRateMonoWriter.java (renamed from src/com/jsyn/unitgen/FixedRateMonoWriter.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FixedRateStereoReader.java (renamed from src/com/jsyn/unitgen/FixedRateStereoReader.java) | 10 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FixedRateStereoWriter.java (renamed from src/com/jsyn/unitgen/FixedRateStereoWriter.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FourWayFade.java (renamed from src/com/jsyn/unitgen/FourWayFade.java) | 2 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FunctionEvaluator.java (renamed from src/com/jsyn/unitgen/FunctionEvaluator.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/FunctionOscillator.java (renamed from src/com/jsyn/unitgen/FunctionOscillator.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Grain.java (renamed from src/com/jsyn/unitgen/Grain.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/GrainCommon.java (renamed from src/com/jsyn/unitgen/GrainCommon.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/GrainEnvelope.java (renamed from src/com/jsyn/unitgen/GrainEnvelope.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/GrainFarm.java (renamed from src/com/jsyn/unitgen/GrainFarm.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/GrainScheduler.java (renamed from src/com/jsyn/unitgen/GrainScheduler.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/GrainSource.java (renamed from src/com/jsyn/unitgen/GrainSource.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/GrainSourceSine.java (renamed from src/com/jsyn/unitgen/GrainSourceSine.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/IFFT.java (renamed from src/com/jsyn/unitgen/IFFT.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/ImpulseOscillator.java (renamed from src/com/jsyn/unitgen/ImpulseOscillator.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/ImpulseOscillatorBL.java (renamed from src/com/jsyn/unitgen/ImpulseOscillatorBL.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Integrate.java (renamed from src/com/jsyn/unitgen/Integrate.java) | 10 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/InterpolatingDelay.java (renamed from src/com/jsyn/unitgen/InterpolatingDelay.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Latch.java (renamed from src/com/jsyn/unitgen/Latch.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/LatchZeroCrossing.java (renamed from src/com/jsyn/unitgen/LatchZeroCrossing.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/LineIn.java (renamed from src/com/jsyn/unitgen/LineIn.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/LineOut.java (renamed from src/com/jsyn/unitgen/LineOut.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/LinearRamp.java (renamed from src/com/jsyn/unitgen/LinearRamp.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Maximum.java (renamed from src/com/jsyn/unitgen/Maximum.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Minimum.java (renamed from src/com/jsyn/unitgen/Minimum.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/MixerMono.java (renamed from src/com/jsyn/unitgen/MixerMono.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/MixerMonoRamped.java (renamed from src/com/jsyn/unitgen/MixerMonoRamped.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/MixerStereo.java (renamed from src/com/jsyn/unitgen/MixerStereo.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/MixerStereoRamped.java (renamed from src/com/jsyn/unitgen/MixerStereoRamped.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/MonoStreamWriter.java (renamed from src/com/jsyn/unitgen/MonoStreamWriter.java) | 2 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/MorphingOscillatorBL.java (renamed from src/com/jsyn/unitgen/MorphingOscillatorBL.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/MultiPassThrough.java (renamed from src/com/jsyn/unitgen/MultiPassThrough.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Multiply.java (renamed from src/com/jsyn/unitgen/Multiply.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/MultiplyAdd.java (renamed from src/com/jsyn/unitgen/MultiplyAdd.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Pan.java (renamed from src/com/jsyn/unitgen/Pan.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/PanControl.java (renamed from src/com/jsyn/unitgen/PanControl.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/ParabolicEnvelope.java (renamed from src/com/jsyn/unitgen/ParabolicEnvelope.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/PassThrough.java (renamed from src/com/jsyn/unitgen/PassThrough.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/PeakFollower.java (renamed from src/com/jsyn/unitgen/PeakFollower.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/PhaseShifter.java (renamed from src/com/jsyn/unitgen/PhaseShifter.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/PinkNoise.java (renamed from src/com/jsyn/unitgen/PinkNoise.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/PitchDetector.java (renamed from src/com/jsyn/unitgen/PitchDetector.java) | 15 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/PitchToFrequency.java (renamed from src/com/jsyn/unitgen/PitchToFrequency.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/PowerOfTwo.java (renamed from src/com/jsyn/unitgen/PowerOfTwo.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/PulseOscillator.java (renamed from src/com/jsyn/unitgen/PulseOscillator.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/PulseOscillatorBL.java (renamed from src/com/jsyn/unitgen/PulseOscillatorBL.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/RaisedCosineEnvelope.java (renamed from src/com/jsyn/unitgen/RaisedCosineEnvelope.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/RangeConverter.java (renamed from src/com/jsyn/unitgen/RangeConverter.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/RectangularWindow.java (renamed from src/com/jsyn/unitgen/RectangularWindow.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/RedNoise.java (renamed from src/com/jsyn/unitgen/RedNoise.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SampleGrainFarm.java (renamed from src/com/jsyn/unitgen/SampleGrainFarm.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SampleGrainSource.java (renamed from src/com/jsyn/unitgen/SampleGrainSource.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SawtoothOscillator.java (renamed from src/com/jsyn/unitgen/SawtoothOscillator.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SawtoothOscillatorBL.java (renamed from src/com/jsyn/unitgen/SawtoothOscillatorBL.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SawtoothOscillatorDPW.java (renamed from src/com/jsyn/unitgen/SawtoothOscillatorDPW.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SchmidtTrigger.java (renamed from src/com/jsyn/unitgen/SchmidtTrigger.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Select.java (renamed from src/com/jsyn/unitgen/Select.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SequentialDataReader.java (renamed from src/com/jsyn/unitgen/SequentialDataReader.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SequentialDataWriter.java (renamed from src/com/jsyn/unitgen/SequentialDataWriter.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SineOscillator.java (renamed from src/com/jsyn/unitgen/SineOscillator.java) | 11 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SineOscillatorPhaseModulated.java (renamed from src/com/jsyn/unitgen/SineOscillatorPhaseModulated.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SpectralFFT.java (renamed from src/com/jsyn/unitgen/SpectralFFT.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SpectralFilter.java (renamed from src/com/jsyn/unitgen/SpectralFilter.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SpectralIFFT.java (renamed from src/com/jsyn/unitgen/SpectralIFFT.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SpectralProcessor.java (renamed from src/com/jsyn/unitgen/SpectralProcessor.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SquareOscillator.java (renamed from src/com/jsyn/unitgen/SquareOscillator.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/SquareOscillatorBL.java (renamed from src/com/jsyn/unitgen/SquareOscillatorBL.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/StereoStreamWriter.java (renamed from src/com/jsyn/unitgen/StereoStreamWriter.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/StochasticGrainScheduler.java (renamed from src/com/jsyn/unitgen/StochasticGrainScheduler.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Subtract.java (renamed from src/com/jsyn/unitgen/Subtract.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/TriangleOscillator.java (renamed from src/com/jsyn/unitgen/TriangleOscillator.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/TunableFilter.java (renamed from src/com/jsyn/unitgen/TunableFilter.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/TwoInDualOut.java (renamed from src/com/jsyn/unitgen/TwoInDualOut.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/UnitBinaryOperator.java (renamed from src/com/jsyn/unitgen/UnitBinaryOperator.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/UnitFilter.java (renamed from src/com/jsyn/unitgen/UnitFilter.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/UnitGate.java (renamed from src/com/jsyn/unitgen/UnitGate.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/UnitGenerator.java (renamed from src/com/jsyn/unitgen/UnitGenerator.java) | 26 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/UnitOscillator.java (renamed from src/com/jsyn/unitgen/UnitOscillator.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/UnitSink.java (renamed from src/com/jsyn/unitgen/UnitSink.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/UnitSource.java (renamed from src/com/jsyn/unitgen/UnitSource.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/UnitStreamWriter.java (renamed from src/com/jsyn/unitgen/UnitStreamWriter.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/UnitVoice.java (renamed from src/com/jsyn/unitgen/UnitVoice.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/Unzipper.java (renamed from src/com/jsyn/unitgen/Unzipper.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/VariableRateDataReader.java (renamed from src/com/jsyn/unitgen/VariableRateDataReader.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/VariableRateMonoReader.java (renamed from src/com/jsyn/unitgen/VariableRateMonoReader.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/VariableRateStereoReader.java (renamed from src/com/jsyn/unitgen/VariableRateStereoReader.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/WhiteNoise.java (renamed from src/com/jsyn/unitgen/WhiteNoise.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/unitgen/ZeroCrossingCounter.java (renamed from src/com/jsyn/unitgen/ZeroCrossingCounter.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/AudioSampleLoader.java (renamed from src/com/jsyn/util/AudioSampleLoader.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/AudioStreamReader.java (renamed from src/com/jsyn/util/AudioStreamReader.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/AutoCorrelator.java (renamed from src/com/jsyn/util/AutoCorrelator.java) | 19 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/Instrument.java (renamed from src/com/jsyn/util/Instrument.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/InstrumentLibrary.java (renamed from src/com/jsyn/util/InstrumentLibrary.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/JavaSoundSampleLoader.java (renamed from src/com/jsyn/util/JavaSoundSampleLoader.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/JavaTools.java (renamed from src/com/jsyn/util/JavaTools.java) | 17 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/MultiChannelSynthesizer.java (renamed from src/com/jsyn/util/MultiChannelSynthesizer.java) | 6 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/NumericOutput.java (renamed from src/com/jsyn/util/NumericOutput.java) | 60 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/PolyphonicInstrument.java (renamed from src/com/jsyn/util/PolyphonicInstrument.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/PseudoRandom.java (renamed from src/com/jsyn/util/PseudoRandom.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/RecursiveSequenceGenerator.java (renamed from src/com/jsyn/util/RecursiveSequenceGenerator.java) | 16 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/SampleLoader.java (renamed from src/com/jsyn/util/SampleLoader.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/SignalCorrelator.java (renamed from src/com/jsyn/util/SignalCorrelator.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/StreamingThread.java (renamed from src/com/jsyn/util/StreamingThread.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/TransportListener.java (renamed from src/com/jsyn/util/TransportListener.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/TransportModel.java (renamed from src/com/jsyn/util/TransportModel.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/VoiceAllocator.java (renamed from src/com/jsyn/util/VoiceAllocator.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/VoiceDescription.java (renamed from src/com/jsyn/util/VoiceDescription.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/VoiceOperation.java (renamed from src/com/jsyn/util/VoiceOperation.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/WaveFileWriter.java (renamed from src/com/jsyn/util/WaveFileWriter.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/WaveRecorder.java (renamed from src/com/jsyn/util/WaveRecorder.java) | 10 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/soundfile/AIFFFileParser.java (renamed from src/com/jsyn/util/soundfile/AIFFFileParser.java) | 23 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/soundfile/AudioFileParser.java (renamed from src/com/jsyn/util/soundfile/AudioFileParser.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/soundfile/ChunkHandler.java (renamed from src/com/jsyn/util/soundfile/ChunkHandler.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/soundfile/CustomSampleLoader.java (renamed from src/com/jsyn/util/soundfile/CustomSampleLoader.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/soundfile/IFFParser.java (renamed from src/com/jsyn/util/soundfile/IFFParser.java) | 38 | ||||
-rw-r--r-- | src/main/java/com/jsyn/util/soundfile/WAVEFileParser.java (renamed from src/com/jsyn/util/soundfile/WAVEFileParser.java) | 36 | ||||
-rw-r--r-- | src/main/java/com/softsynth/math/AudioMath.java (renamed from src/com/softsynth/math/AudioMath.java) | 6 | ||||
-rw-r--r-- | src/main/java/com/softsynth/math/ChebyshevPolynomial.java (renamed from src/com/softsynth/math/ChebyshevPolynomial.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/softsynth/math/FourierMath.java (renamed from src/com/softsynth/math/FourierMath.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/softsynth/math/JustRatio.java (renamed from src/com/softsynth/math/JustRatio.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/softsynth/math/Polynomial.java (renamed from src/com/softsynth/math/Polynomial.java) | 40 | ||||
-rw-r--r-- | src/main/java/com/softsynth/math/PolynomialTableData.java (renamed from src/com/softsynth/math/PolynomialTableData.java) | 10 | ||||
-rw-r--r-- | src/main/java/com/softsynth/math/PrimeFactors.java (renamed from src/com/softsynth/math/PrimeFactors.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/softsynth/shared/time/ScheduledCommand.java (renamed from src/com/softsynth/shared/time/ScheduledCommand.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/softsynth/shared/time/ScheduledQueue.java (renamed from src/com/softsynth/shared/time/ScheduledQueue.java) | 0 | ||||
-rw-r--r-- | src/main/java/com/softsynth/shared/time/TimeStamp.java (renamed from src/com/softsynth/shared/time/TimeStamp.java) | 0 | ||||
-rw-r--r-- | src/main/resources/log4j.xml | 15 | ||||
-rw-r--r-- | src/test/java/com/jsyn/benchmarks/BenchJSyn.java (renamed from tests/com/jsyn/benchmarks/BenchJSyn.java) | 44 | ||||
-rw-r--r-- | src/test/java/com/jsyn/data/TestShortSample.java (renamed from tests/com/jsyn/data/TestShortSample.java) | 32 | ||||
-rw-r--r-- | src/test/java/com/jsyn/engine/TestAudioOutput.java (renamed from tests/com/jsyn/engine/TestAudioOutput.java) | 30 | ||||
-rw-r--r-- | src/test/java/com/jsyn/engine/TestDevices.java (renamed from tests/com/jsyn/engine/TestDevices.java) | 24 | ||||
-rw-r--r-- | src/test/java/com/jsyn/engine/TestEngine.java (renamed from tests/com/jsyn/engine/TestEngine.java) | 66 | ||||
-rw-r--r-- | src/test/java/com/jsyn/engine/TestFifo.java (renamed from tests/com/jsyn/engine/TestFifo.java) | 165 | ||||
-rw-r--r-- | src/test/java/com/jsyn/engine/TestWaveFileReadWrite.java (renamed from tests/com/jsyn/engine/TestWaveFileReadWrite.java) | 57 | ||||
-rw-r--r-- | src/test/java/com/jsyn/midi/TestMidiLoop.java (renamed from tests/com/jsyn/midi/TestMidiLoop.java) | 43 | ||||
-rw-r--r-- | src/test/java/com/jsyn/ports/TestQueuedDataPort.java (renamed from tests/com/jsyn/ports/TestQueuedDataPort.java) | 158 | ||||
-rw-r--r-- | src/test/java/com/jsyn/ports/TestSequentialData.java (renamed from tests/com/jsyn/ports/TestSequentialData.java) | 33 | ||||
-rw-r--r-- | src/test/java/com/jsyn/ports/TestSet.java (renamed from tests/com/jsyn/ports/TestSet.java) | 43 | ||||
-rw-r--r-- | src/test/java/com/jsyn/research/BenchMultiThreading.java (renamed from tests/com/jsyn/research/BenchMultiThreading.java) | 31 | ||||
-rw-r--r-- | src/test/java/com/jsyn/research/RecordVariousRamps.java (renamed from tests/com/jsyn/research/RecordVariousRamps.java) | 38 | ||||
-rw-r--r-- | src/test/java/com/jsyn/swing/TestRangeModels.java (renamed from tests/com/jsyn/swing/TestRangeModels.java) | 37 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/CalibrateMoogFilter.java (renamed from tests/com/jsyn/unitgen/CalibrateMoogFilter.java) | 8 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/EnablingGate.java (renamed from tests/com/jsyn/unitgen/EnablingGate.java) | 0 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/NonRealTimeTestCase.java (renamed from tests/com/jsyn/unitgen/NonRealTimeTestCase.java) | 24 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/RecordMoogFilter.java (renamed from tests/com/jsyn/unitgen/RecordMoogFilter.java) | 15 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/TestConnections.java (renamed from tests/com/jsyn/unitgen/TestConnections.java) | 46 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/TestDelay.java (renamed from tests/com/jsyn/unitgen/TestDelay.java) | 16 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/TestEnable.java (renamed from tests/com/jsyn/unitgen/TestEnable.java) | 43 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/TestEnvelopeAttackDecay.java (renamed from tests/com/jsyn/unitgen/TestEnvelopeAttackDecay.java) | 54 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/TestEnvelopeDAHDSR.java (renamed from tests/com/jsyn/unitgen/TestEnvelopeDAHDSR.java) | 86 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/TestFunction.java (renamed from tests/com/jsyn/unitgen/TestFunction.java) | 45 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/TestMath.java (renamed from tests/com/jsyn/unitgen/TestMath.java) | 201 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/TestRamps.java (renamed from tests/com/jsyn/unitgen/TestRamps.java) | 61 | ||||
-rw-r--r-- | src/test/java/com/jsyn/unitgen/TestUnitGate.java (renamed from tests/com/jsyn/unitgen/TestUnitGate.java) | 25 | ||||
-rw-r--r-- | src/test/java/com/jsyn/util/DebugSampleLoader.java (renamed from tests/com/jsyn/util/DebugSampleLoader.java) | 27 | ||||
-rw-r--r-- | src/test/java/com/jsyn/util/TestFFT.java (renamed from tests/com/jsyn/util/TestFFT.java) | 30 | ||||
-rw-r--r-- | src/test/java/com/jsyn/util/TestPseudoRandom.java (renamed from tests/com/jsyn/util/TestPseudoRandom.java) | 40 | ||||
-rw-r--r-- | src/test/java/com/jsyn/util/TestVoiceAllocator.java (renamed from tests/com/jsyn/util/TestVoiceAllocator.java) | 60 | ||||
-rw-r--r-- | tests/com/jsyn/SynthTestSuite.java | 76 | ||||
-rw-r--r-- | tests/com/jsyn/research/lambdas/LambdaUnits.java | 22 |
347 files changed, 1946 insertions, 1494 deletions
diff --git a/.classpath b/.classpath deleted file mode 100644 index bb47eaa..0000000 --- a/.classpath +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="tests"/> - <classpathentry kind="lib" path="libs/jportaudio.jar"/> - <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="output" path="bin"/> -</classpath> @@ -1,6 +1,10 @@ -# ignore Eclipse and Ant generated directories -/build/ -/bin/ -/dist/ -/doc/ +build/ +.gradle/ +# Ignore IDE data to push towards a universally Gradle controlled environment +.idea/ +.classpath +.project + +# A temporary file sometimes generated +temp_recording.wav diff --git a/.project b/.project deleted file mode 100644 index 2ba0678..0000000 --- a/.project +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>JSyn</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/DEVELOPING.md b/DEVELOPING.md new file mode 100644 index 0000000..5dc7202 --- /dev/null +++ b/DEVELOPING.md @@ -0,0 +1,44 @@ +## Developing + +With the new inclusion of Gradle replacing ant (bye bye 2014) this brings some more modern features. Running any of the commands will automatically install the Gradle wrapper, no other install needed. This uses Gradle 6.5.1 and Java 11. + +### Run The Demo + +``` +./gradlew run +``` + +### Javadoc generation + +``` +./gradlew javadoc +``` + +### Building Jar + +``` +./gradlew shadowJar +``` + +### Publish To Maven Local + +This allows you to use JSyn as a maven/gradle repository on your machine. + +``` +./gradlew publishToMavenLocal +``` + +It can be used via + +```groovy +repositories { + // ... + mavenLocal() +} + +dependencies { + // ... + implementation 'com.jsyn:jsyn:17.0.0-SNAPSHOT' +} +``` + diff --git a/README.txt b/README.txt deleted file mode 100644 index 96dc92f..0000000 --- a/README.txt +++ /dev/null @@ -1 +0,0 @@ -See README.md diff --git a/android/README.md b/android/README.md new file mode 100644 index 0000000..95a6a56 --- /dev/null +++ b/android/README.md @@ -0,0 +1,2 @@ +I'm not quite sure where to place this file. This has Android dependencies and from what I can tell was previously floating in this unrelated folder named `android`. From what I can tell, the intent is to place this class into your Android project when using it. + diff --git a/android/com/jsyn/devices/android/AndroidAudioForJSyn.java b/android/com/jsyn/devices/android/AndroidAudioForJSyn.java index 3aba1e4..20bbb68 100644 --- a/android/com/jsyn/devices/android/AndroidAudioForJSyn.java +++ b/android/com/jsyn/devices/android/AndroidAudioForJSyn.java @@ -84,9 +84,9 @@ public class AndroidAudioForJSyn implements AudioDeviceManager { minBufferSize = AudioTrack.getMinBufferSize(frameRate, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_FLOAT); - System.out.println("Audio minBufferSize = " + minBufferSize); + LOGGER.debug("Audio minBufferSize = " + minBufferSize); bufferSize = (3 * (minBufferSize / 2)) & ~3; - System.out.println("Audio bufferSize = " + bufferSize); + LOGGER.debug("Audio bufferSize = " + bufferSize); audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, frameRate, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_FLOAT, bufferSize, diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..047aba8 --- /dev/null +++ b/build.gradle @@ -0,0 +1,60 @@ +plugins { + id 'java' + id 'application' + id 'maven-publish' + id 'com.github.johnrengelman.shadow' version '6.0.0' +} + +group = 'com.jsyn' +version = '17.0.0-SNAPSHOT' +sourceCompatibility = '11' +mainClassName = 'com.jsyn.apps.AboutJSyn' + +repositories { + mavenCentral() + mavenLocal() +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2' + + implementation 'org.slf4j:slf4j-api:1.7.25' + implementation 'org.slf4j:slf4j-log4j12:1.7.25' + + implementation fileTree(dir: 'libs', include: '*.jar') +} + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } + repositories { + mavenLocal() + } +} + +jar { + manifest { + attributes('Main-Class': mainClassName) + } +} +shadowJar { + archiveFileName = "jysn-${version}.jar"; +} + +javadoc { + exclude 'com/portaudio/**' + exclude 'com/jsyn/devices/jportaudio/**' + source = sourceSets.main.allJava + + options { + addStringOption('Xdoclint:none', '-quiet') + } +} + +test { + useJUnitPlatform() +} + diff --git a/build.xml b/build.xml deleted file mode 100644 index e436ef2..0000000 --- a/build.xml +++ /dev/null @@ -1,66 +0,0 @@ -<project name="JSynProject" default="dist" basedir="."> - <description> - Build JSyn Java Synthesizer - </description> - <!-- set global properties for this build --> - <property name="src.dir" location="src"/> - <property name="doc.dir" location="doc"/> - <property name="build.dir" location="build"/> - <property name="dist" location="dist"/> - <property name="main-class" value="com.jsyn.apps.AboutJSyn"/> - <property name="jarname" value="jsyn"/> - <property name="java-version" value="1.8"/> - - <target name="init"> - <!-- Create the time stamp --> - <tstamp/> - <!-- Create the necessary directories. --> - <mkdir dir="${build.dir}"/> - <mkdir dir="${doc.dir}"/> - </target> - - <target name="compile" depends="init" - description="compile the source " > - <!-- Compile the java code from ${src} into ${build} --> - <javac target="${java-version}" source="${java-version}" - srcdir="${src.dir}" destdir="${build.dir}"> - <classpath> - <pathelement path="libs/jportaudio.jar"/> - </classpath> - </javac> - </target> - - <target name="dist" depends="compile" - description="generate the distribution" > - <!-- Create the distribution directory --> - <mkdir dir="${dist}/lib"/> - - <!-- Put everything in ${build} into the jsyn-${DSTAMP}.jar file --> - <jar jarfile="${dist}/lib/${jarname}-${DSTAMP}.jar" basedir="${build.dir}"> - <manifest> - <attribute name="Main-Class" value="${main-class}"/> - </manifest> - </jar> - </target> - - <!-- Generate javadocs for current project into ${doc.dir} --> - <target name="doc" depends="init" description="generate documentation"> - <javadoc - sourcepath="${src.dir}" - destdir="${doc.dir}" - packagenames="com.jsyn.*" - excludepackagenames="com.portaudio,com.jsyn.devices.jportaudio" - /> - <echo message = "=================================================================" /> - <echo message = "Javadocs have been generated and placed in the ${doc.dir} folder!" /> - <echo message = "=================================================================" /> - </target> - - <target name="clean" - description="clean up" > - <!-- Delete the directories created by ant. --> - <delete dir="${build.dir}"/> - <delete dir="${doc.dir}"/> - <delete dir="${dist}"/> - </target> -</project> diff --git a/examples/build.gradle b/examples/build.gradle new file mode 100644 index 0000000..b3a9ef1 --- /dev/null +++ b/examples/build.gradle @@ -0,0 +1,14 @@ +apply plugin: 'java' + +version = '17.0.0-SNAPSHOT' + +repositories { + mavenCentral() +} + +dependencies { + implementation project(':') + + implementation 'org.slf4j:slf4j-api:1.7.25' + implementation 'org.slf4j:slf4j-log4j12:1.7.25' +} diff --git a/tests/com/jsyn/examples/AudioPassThrough.java b/examples/src/main/java/com/jsyn/examples/AudioPassThrough.java index fb46992..383dba4 100644 --- a/tests/com/jsyn/examples/AudioPassThrough.java +++ b/examples/src/main/java/com/jsyn/examples/AudioPassThrough.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,24 +17,27 @@ package com.jsyn.examples; import com.jsyn.JSyn; -import com.jsyn.Synthesizer; import com.jsyn.devices.AudioDeviceManager; import com.jsyn.unitgen.LineIn; import com.jsyn.unitgen.LineOut; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Pass audio input to audio output. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class AudioPassThrough { - Synthesizer synth; - LineIn lineIn; - LineOut lineOut; + + private static final Logger LOGGER = LoggerFactory.getLogger(AudioPassThrough.class); private void test() { + LineIn lineIn; + LineOut lineOut; + // Create a context for the synthesizer. - synth = JSyn.createSynthesizer(); + var synth = JSyn.createSynthesizer(); // Add an audio input. synth.add(lineIn = new LineIn()); // Add an audio output. @@ -51,7 +54,7 @@ public class AudioPassThrough { // We only need to start the LineOut. It will pull data from the LineIn. lineOut.start(); - System.out.println("Audio passthrough started."); + LOGGER.debug("Audio passthrough started."); // Sleep a while. try { double time = synth.getCurrentTime(); @@ -62,7 +65,7 @@ public class AudioPassThrough { } // Stop everything. synth.stop(); - System.out.println("All done."); + LOGGER.debug("All done."); } public static void main(String[] args) { diff --git a/tests/com/jsyn/examples/ChebyshevSong.java b/examples/src/main/java/com/jsyn/examples/ChebyshevSong.java index fffd4bb..6acd894 100644 --- a/tests/com/jsyn/examples/ChebyshevSong.java +++ b/examples/src/main/java/com/jsyn/examples/ChebyshevSong.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,14 +31,18 @@ import com.jsyn.util.PseudoRandom; import com.jsyn.util.VoiceAllocator; import com.softsynth.math.AudioMath; import com.softsynth.shared.time.TimeStamp; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /*************************************************************** * Play notes using a WaveShapingVoice. Allocate the notes using a VoiceAllocator. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class ChebyshevSong extends JApplet implements Runnable { - private static final long serialVersionUID = -7459137388629333223L; + + private static final Logger LOGGER = LoggerFactory.getLogger(ChebyshevSong.class); + private Synthesizer synth; private Add mixer; private LineOut lineOut; @@ -53,7 +57,7 @@ public class ChebyshevSong extends JApplet implements Runnable { }; // pentatonic scale /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { ChebyshevSong applet = new ChebyshevSong(); JAppletFrame frame = new JAppletFrame("ChebyshevSong", applet); frame.setSize(640, 300); @@ -175,7 +179,7 @@ public class ChebyshevSong extends JApplet implements Runnable { synth.sleepUntil(nextTime - advanceTime); } while (go); } catch (InterruptedException e) { - System.err.println("Song exiting. " + e); + LOGGER.error("Song exiting", e); } } } diff --git a/tests/com/jsyn/examples/CircuitTester.java b/examples/src/main/java/com/jsyn/examples/CircuitTester.java index 948e8a0..0a429fb 100644 --- a/tests/com/jsyn/examples/CircuitTester.java +++ b/examples/src/main/java/com/jsyn/examples/CircuitTester.java @@ -23,7 +23,6 @@ import javax.swing.JApplet; import com.jsyn.JSyn; import com.jsyn.Synthesizer; import com.jsyn.instruments.DualOscillatorSynthVoice; -import com.jsyn.instruments.SubtractiveSynthVoice; import com.jsyn.scope.AudioScope; import com.jsyn.swing.JAppletFrame; import com.jsyn.swing.SoundTweaker; @@ -36,7 +35,6 @@ import com.jsyn.unitgen.UnitSource; * @author Phil Burk (C) 2012 Mobileer Inc */ public class CircuitTester extends JApplet { - private static final long serialVersionUID = -2704222221111608377L; private Synthesizer synth; private LineOut lineOut; private SoundTweaker tweaker; @@ -102,7 +100,7 @@ public class CircuitTester extends JApplet { } /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { CircuitTester applet = new CircuitTester(); JAppletFrame frame = new JAppletFrame("JSyn Circuit Tester", applet); frame.setSize(600, 600); diff --git a/tests/com/jsyn/examples/CustomCubeUnit.java b/examples/src/main/java/com/jsyn/examples/CustomCubeUnit.java index 892c30c..897052c 100644 --- a/tests/com/jsyn/examples/CustomCubeUnit.java +++ b/examples/src/main/java/com/jsyn/examples/CustomCubeUnit.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,12 +21,11 @@ import com.jsyn.unitgen.UnitFilter; /** * Custom unit generator that can be used with other JSyn units. Cube the input value and write it * to output port. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class CustomCubeUnit extends UnitFilter { - @Override /** This is where the synthesis occurs. * It is called in a high priority background thread so do not do * anything crazy here like reading a file or doing network I/O. @@ -34,6 +33,7 @@ public class CustomCubeUnit extends UnitFilter { * <br> * The start and limit allow us to do either block or single sample processing. */ + @Override public void generate(int start, int limit) { // Get signal arrays from ports. double[] inputs = input.getValues(); diff --git a/tests/com/jsyn/examples/DualOscilloscope.java b/examples/src/main/java/com/jsyn/examples/DualOscilloscope.java index d7798f4..2c4caa3 100644 --- a/tests/com/jsyn/examples/DualOscilloscope.java +++ b/examples/src/main/java/com/jsyn/examples/DualOscilloscope.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,11 +35,10 @@ import com.jsyn.unitgen.PassThrough; /** * Two channel oscilloscope that demonstrates the use of audio input. - * + * * @author Phil Burk (C) 2012 Mobileer Inc */ public class DualOscilloscope extends JApplet { - private static final long serialVersionUID = -2704222221111608377L; private Synthesizer synth; private ChannelIn channel1; private ChannelIn channel2; @@ -153,7 +152,7 @@ public class DualOscilloscope extends JApplet { } /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { DualOscilloscope applet = new DualOscilloscope(); JAppletFrame frame = new JAppletFrame("Dual Oscilloscope", applet); frame.setSize(640, 400); diff --git a/tests/com/jsyn/examples/EditEnvelope1.java b/examples/src/main/java/com/jsyn/examples/EditEnvelope1.java index 763037b..997b8b4 100644 --- a/tests/com/jsyn/examples/EditEnvelope1.java +++ b/examples/src/main/java/com/jsyn/examples/EditEnvelope1.java @@ -4,16 +4,16 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -/** +/** * Test Envelope using Java Audio Synthesizer * Trigger attack or release portion. * @@ -57,7 +57,7 @@ public class EditEnvelope1 extends JApplet { private EnvelopePoints points; /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { EditEnvelope1 applet = new EditEnvelope1(); JAppletFrame frame = new JAppletFrame("Test SynthEnvelope", applet); frame.setSize(440, 200); diff --git a/tests/com/jsyn/examples/FFTPassthrough.java b/examples/src/main/java/com/jsyn/examples/FFTPassthrough.java index 1a1a7c5..e4b72c8 100644 --- a/tests/com/jsyn/examples/FFTPassthrough.java +++ b/examples/src/main/java/com/jsyn/examples/FFTPassthrough.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,13 +24,18 @@ import com.jsyn.unitgen.SineOscillator; import com.jsyn.unitgen.SpectralFFT; import com.jsyn.unitgen.SpectralIFFT; import com.jsyn.unitgen.UnitOscillator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Play a sine sweep through an FFT/IFFT pair. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class FFTPassthrough { + + private static final Logger LOGGER = LoggerFactory.getLogger(FFTPassthrough.class); + private Synthesizer synth; private PassThrough center; private UnitOscillator osc; @@ -77,8 +82,8 @@ public class FFTPassthrough { // chain. lineOut.start(); - System.out.println("You should now be hearing a clean oscillator on the left channel,"); - System.out.println("and the FFT->IFFT processed signal on the right channel."); + LOGGER.debug("You should now be hearing a clean oscillator on the left channel,"); + LOGGER.debug("and the FFT->IFFT processed signal on the right channel."); // Sleep while the sound is generated in the background. try { @@ -89,7 +94,7 @@ public class FFTPassthrough { e.printStackTrace(); } - System.out.println("Stop playing. -------------------"); + LOGGER.debug("Stop playing. -------------------"); // Stop everything. synth.stop(); } diff --git a/tests/com/jsyn/examples/GoogleWaveOscillator.java b/examples/src/main/java/com/jsyn/examples/GoogleWaveOscillator.java index 2f45cc4..cf76298 100644 --- a/tests/com/jsyn/examples/GoogleWaveOscillator.java +++ b/examples/src/main/java/com/jsyn/examples/GoogleWaveOscillator.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,7 +21,7 @@ import com.jsyn.unitgen.UnitOscillator; /** * Custom unit generator to create the waveform shown on the Google home page on 2/22/12. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class GoogleWaveOscillator extends UnitOscillator { @@ -44,8 +44,7 @@ public class GoogleWaveOscillator extends UnitOscillator { for (int i = start; i < limit; i++) { if (currentPhase > 0.0) { - double p = currentPhase; - y = Math.sqrt(4.0 * (p * (1.0 - p))); + y = Math.sqrt(4.0 * (currentPhase * (1.0 - currentPhase))); } else { double p = -currentPhase; y = -Math.sqrt(4.0 * (p * (1.0 - p))); diff --git a/tests/com/jsyn/examples/HearDAHDSR.java b/examples/src/main/java/com/jsyn/examples/HearDAHDSR.java index 23e6fb5..a6c03aa 100644 --- a/tests/com/jsyn/examples/HearDAHDSR.java +++ b/examples/src/main/java/com/jsyn/examples/HearDAHDSR.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,14 +33,18 @@ import com.jsyn.unitgen.LineOut; import com.jsyn.unitgen.SineOscillator; import com.jsyn.unitgen.SquareOscillator; import com.jsyn.unitgen.UnitOscillator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Play a tone using a JSyn oscillator. Modulate the amplitude using a DAHDSR envelope. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class HearDAHDSR extends JApplet { - private static final long serialVersionUID = -2704222221111608377L; + + private static final Logger LOGGER = LoggerFactory.getLogger(HearDAHDSR.class); + private Synthesizer synth; private UnitOscillator osc; // Use a square wave to trigger the envelope. @@ -90,7 +94,7 @@ public class HearDAHDSR extends JApplet { private void setupPortKnob(UnitInputPort port) { DoubleBoundedRangeModel model = PortModelFactory.createExponentialModel(port); - System.out.println("Make knob for " + port.getName() + ", model.getDV = " + LOGGER.debug("Make knob for " + port.getName() + ", model.getDV = " + model.getDoubleValue() + ", model.getV = " + model.getValue() + ", port.getV = " + port.get()); RotaryTextController knob = new RotaryTextController(model, 10); @@ -114,7 +118,7 @@ public class HearDAHDSR extends JApplet { } /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { HearDAHDSR applet = new HearDAHDSR(); JAppletFrame frame = new JAppletFrame("Hear DAHDSR Envelope", applet); frame.setSize(640, 200); diff --git a/tests/com/jsyn/examples/HearMoogFilter.java b/examples/src/main/java/com/jsyn/examples/HearMoogFilter.java index 4ec4811..2444dd7 100644 --- a/tests/com/jsyn/examples/HearMoogFilter.java +++ b/examples/src/main/java/com/jsyn/examples/HearMoogFilter.java @@ -33,7 +33,6 @@ import com.jsyn.JSyn; import com.jsyn.Synthesizer; import com.jsyn.ports.UnitInputPort; import com.jsyn.scope.AudioScope; -import com.jsyn.scope.AudioScopeProbe; import com.jsyn.swing.DoubleBoundedRangeModel; import com.jsyn.swing.JAppletFrame; import com.jsyn.swing.PortModelFactory; @@ -197,7 +196,7 @@ public class HearMoogFilter extends JApplet { } /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { HearMoogFilter applet = new HearMoogFilter(); JAppletFrame frame = new JAppletFrame("Hear Moog Style Filter", applet); frame.setSize(800, 600); diff --git a/tests/com/jsyn/examples/HearSinePM.java b/examples/src/main/java/com/jsyn/examples/HearSinePM.java index 1e19505..c567b03 100644 --- a/tests/com/jsyn/examples/HearSinePM.java +++ b/examples/src/main/java/com/jsyn/examples/HearSinePM.java @@ -43,7 +43,6 @@ import com.jsyn.unitgen.SineOscillatorPhaseModulated; * @author Phil Burk (C) 2010 Mobileer Inc */ public class HearSinePM extends JApplet { - private static final long serialVersionUID = -2704222221111608377L; private Synthesizer synth; SineOscillatorPhaseModulated carrier; SineOscillator modulator; @@ -118,7 +117,7 @@ public class HearSinePM extends JApplet { } /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { HearSinePM applet = new HearSinePM(); JAppletFrame frame = new JAppletFrame("Hear Phase Modulation", applet); frame.setSize(640, 400); diff --git a/tests/com/jsyn/examples/HearSpectralFilter.java b/examples/src/main/java/com/jsyn/examples/HearSpectralFilter.java index 93559b4..cc5d8c9 100644 --- a/tests/com/jsyn/examples/HearSpectralFilter.java +++ b/examples/src/main/java/com/jsyn/examples/HearSpectralFilter.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,13 +31,18 @@ import com.jsyn.unitgen.SpectralProcessor; import com.jsyn.unitgen.UnitOscillator; import com.jsyn.unitgen.WhiteNoise; import com.jsyn.util.WaveRecorder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Play a sine sweep through an FFT/IFFT pair. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class HearSpectralFilter { + + private static final Logger LOGGER = LoggerFactory.getLogger(HearSpectralFilter.class); + private Synthesizer synth; private PassThrough center; private UnitOscillator osc; @@ -110,7 +115,7 @@ public class HearSpectralFilter { File waveFile = new File("temp_recording.wav"); // Default is stereo, 16 bits. recorder = new WaveRecorder(synth, waveFile); - System.out.println("Writing to WAV file " + waveFile.getAbsolutePath()); + LOGGER.debug("Writing to WAV file " + waveFile.getAbsolutePath()); } if (useProcessor) { @@ -173,8 +178,8 @@ public class HearSpectralFilter { lineOut.start(); - System.out.println("You should now be hearing a clean oscillator on the left channel,"); - System.out.println("and the FFT->IFFT processed signal on the right channel."); + LOGGER.debug("You should now be hearing a clean oscillator on the left channel,"); + LOGGER.debug("and the FFT->IFFT processed signal on the right channel."); // Sleep while the sound is generated in the background. try { @@ -190,7 +195,7 @@ public class HearSpectralFilter { recorder.close(); } - System.out.println("Stop playing. -------------------"); + LOGGER.debug("Stop playing. -------------------"); // Stop everything. synth.stop(); } diff --git a/tests/com/jsyn/examples/ListAudioDevices.java b/examples/src/main/java/com/jsyn/examples/ListAudioDevices.java index dceaa0d..097ffdc 100644 --- a/tests/com/jsyn/examples/ListAudioDevices.java +++ b/examples/src/main/java/com/jsyn/examples/ListAudioDevices.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,9 +18,13 @@ package com.jsyn.examples; import com.jsyn.devices.AudioDeviceFactory; import com.jsyn.devices.AudioDeviceManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ListAudioDevices { + private static final Logger LOGGER = LoggerFactory.getLogger(ListAudioDevices.class); + /** * @param args */ @@ -34,10 +38,10 @@ public class ListAudioDevices { int maxOutputs = audioManager.getMaxInputChannels(i); boolean isDefaultInput = (i == audioManager.getDefaultInputDeviceID()); boolean isDefaultOutput = (i == audioManager.getDefaultOutputDeviceID()); - System.out.println("#" + i + " : " + deviceName); - System.out.println(" max inputs : " + maxInputs + LOGGER.debug("#" + i + " : " + deviceName); + LOGGER.debug(" max inputs : " + maxInputs + (isDefaultInput ? " (default)" : "")); - System.out.println(" max outputs: " + maxOutputs + LOGGER.debug(" max outputs: " + maxOutputs + (isDefaultOutput ? " (default)" : "")); } diff --git a/tests/com/jsyn/examples/LongEcho.java b/examples/src/main/java/com/jsyn/examples/LongEcho.java index 0a86efd..16e71f3 100644 --- a/tests/com/jsyn/examples/LongEcho.java +++ b/examples/src/main/java/com/jsyn/examples/LongEcho.java @@ -30,6 +30,8 @@ import com.jsyn.unitgen.FixedRateMonoWriter; import com.jsyn.unitgen.Maximum; import com.jsyn.unitgen.Minimum; import com.jsyn.util.WaveFileWriter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Echo the input using a circular buffer in a sample. @@ -37,6 +39,9 @@ import com.jsyn.util.WaveFileWriter; * @author Phil Burk (C) 2010 Mobileer Inc */ public class LongEcho { + + private static final Logger LOGGER = LoggerFactory.getLogger(LongEcho.class); + final static int DELAY_SECONDS = 4; Synthesizer synth; ChannelIn channelIn; @@ -84,7 +89,7 @@ public class LongEcho { // Loop both forever. reader.dataQueue.queueLoop(sample, 0, sample.getNumFrames()); writer.dataQueue.queueLoop(sample, 0, sample.getNumFrames()); - System.out.println("Start talking. You should hear an echo after " + DELAY_SECONDS + LOGGER.debug("Start talking. You should hear an echo after " + DELAY_SECONDS + " seconds."); // Sleep a while. try { diff --git a/tests/com/jsyn/examples/MonoPassThrough.java b/examples/src/main/java/com/jsyn/examples/MonoPassThrough.java index 0e81abf..0e81abf 100644 --- a/tests/com/jsyn/examples/MonoPassThrough.java +++ b/examples/src/main/java/com/jsyn/examples/MonoPassThrough.java diff --git a/tests/com/jsyn/examples/NotesToTone.java b/examples/src/main/java/com/jsyn/examples/NotesToTone.java index 9186087..a1b06fa 100644 --- a/tests/com/jsyn/examples/NotesToTone.java +++ b/examples/src/main/java/com/jsyn/examples/NotesToTone.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,7 +15,7 @@ */ /** * If you play notes fast enough they become a tone. - * + * * Play a sine wave modulated by an envelope. * Speed up the envelope until it is playing at audio rate. * Slow down the oscillator until it becomes an LFO amp modulator. @@ -40,16 +40,21 @@ import com.jsyn.unitgen.UnitOscillator; import com.jsyn.unitgen.VariableRateDataReader; import com.jsyn.unitgen.VariableRateMonoReader; import com.jsyn.util.WaveRecorder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * When notes speed up they can become a new tone. <br> * Multiply an oscillator and an envelope. Speed up the envelope until it becomes a tone. Slow down * the oscillator until it acts like an envelope. Write the resulting audio to a WAV file. - * + * * @author Phil Burk (C) 2011 Mobileer Inc */ public class NotesToTone { + + private static final Logger LOGGER = LoggerFactory.getLogger(NotesToTone.class); + private final static double SONG_AMPLITUDE = 0.7; private final static double INTRO_DURATION = 2.0; private final static double OUTRO_DURATION = 2.0; @@ -77,7 +82,7 @@ public class NotesToTone { File waveFile = new File("notes_to_tone.wav"); // Default is stereo, 16 bits. recorder = new WaveRecorder(synth, waveFile, 1); - System.out.println("Writing to WAV file " + waveFile.getAbsolutePath()); + LOGGER.debug("Writing to WAV file " + waveFile.getAbsolutePath()); } createUnits(); diff --git a/tests/com/jsyn/examples/PlayChords.java b/examples/src/main/java/com/jsyn/examples/PlayChords.java index 28cab5f..9bd9245 100644 --- a/tests/com/jsyn/examples/PlayChords.java +++ b/examples/src/main/java/com/jsyn/examples/PlayChords.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,7 +27,7 @@ import com.softsynth.shared.time.TimeStamp; /** * Play chords and melody using the VoiceAllocator. - * + * * @author Phil Burk (C) 2009 Mobileer Inc */ public class PlayChords { @@ -99,19 +99,17 @@ public class PlayChords { } private void playMinorMeasure1(double time, int base) throws InterruptedException { - int p1 = base; int p2 = base + 3; int p3 = base + 7; - playChord1(time, p1, p2, p3); - playNoodle1(time, p1 + 24, p2 + 24, p3 + 24); + playChord1(time, base, p2, p3); + playNoodle1(time, base + 24, p2 + 24, p3 + 24); } private void playMajorMeasure1(double time, int base) throws InterruptedException { - int p1 = base; int p2 = base + 4; int p3 = base + 7; - playChord1(time, p1, p2, p3); - playNoodle1(time, p1 + 24, p2 + 24, p3 + 24); + playChord1(time, base, p2, p3); + playNoodle1(time, base + 24, p2 + 24, p3 + 24); } private void playNoodle1(double time, int p1, int p2, int p3) { diff --git a/tests/com/jsyn/examples/PlayCustomUnit.java b/examples/src/main/java/com/jsyn/examples/PlayCustomUnit.java index 609c351..609c351 100644 --- a/tests/com/jsyn/examples/PlayCustomUnit.java +++ b/examples/src/main/java/com/jsyn/examples/PlayCustomUnit.java diff --git a/tests/com/jsyn/examples/PlayFunction.java b/examples/src/main/java/com/jsyn/examples/PlayFunction.java index 700152b..9c389c9 100644 --- a/tests/com/jsyn/examples/PlayFunction.java +++ b/examples/src/main/java/com/jsyn/examples/PlayFunction.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,59 +17,58 @@ package com.jsyn.examples; import com.jsyn.JSyn; -import com.jsyn.Synthesizer; import com.jsyn.data.Function; import com.jsyn.unitgen.FunctionOscillator; import com.jsyn.unitgen.LineOut; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Play a tone using a FunctionOscillator. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class PlayFunction { - Synthesizer synth; - FunctionOscillator osc; - LineOut lineOut; + + private static final Logger LOGGER = LoggerFactory.getLogger(PlayFunction.class); private void test() { // Create a context for the synthesizer. - synth = JSyn.createSynthesizer(); + var synth = JSyn.createSynthesizer(); // Start synthesizer using default stereo output at 44100 Hz. synth.start(); // Add a FunctionOscillator - synth.add(osc = new FunctionOscillator()); + var oscillator = new FunctionOscillator(); + synth.add(oscillator); // Define a function that gives the shape of the waveform. - Function func = new Function() { - @Override - public double evaluate(double input) { - // Input ranges from -1.0 to 1.0 - double s = Math.sin(input * Math.PI * 2.0); - double cubed = s * s * s; - return cubed; - } + Function func = input -> { + // Input ranges from -1.0 to 1.0 + double s = Math.sin(input * Math.PI * 2.0); + return s * s * s; }; - osc.function.set(func); + + oscillator.function.set(func); // Add a stereo audio output unit. - synth.add(lineOut = new LineOut()); + var lineOut = new LineOut(); + synth.add(lineOut); // Connect the oscillator to both channels of the output. - osc.output.connect(0, lineOut.input, 0); - osc.output.connect(0, lineOut.input, 1); + oscillator.output.connect(0, lineOut.input, 0); + oscillator.output.connect(0, lineOut.input, 1); // Set the frequency and amplitude for the sine wave. - osc.frequency.set(345.0); - osc.amplitude.set(0.6); + oscillator.frequency.set(345.0); + oscillator.amplitude.set(0.6); // We only need to start the LineOut. It will pull data from the // oscillator. lineOut.start(); - System.out.println("You should now be hearing a sine wave. ---------"); + LOGGER.debug("You should now be hearing a sine wave. ---------"); // Sleep while the sound is generated in the background. try { @@ -80,7 +79,7 @@ public class PlayFunction { e.printStackTrace(); } - System.out.println("Stop playing. -------------------"); + LOGGER.debug("Stop playing. -------------------"); // Stop everything. synth.stop(); } diff --git a/tests/com/jsyn/examples/PlayGrains.java b/examples/src/main/java/com/jsyn/examples/PlayGrains.java index b9a7b5b..82b390e 100644 --- a/tests/com/jsyn/examples/PlayGrains.java +++ b/examples/src/main/java/com/jsyn/examples/PlayGrains.java @@ -41,6 +41,8 @@ import com.jsyn.unitgen.LineOut; import com.jsyn.unitgen.SampleGrainFarm; import com.jsyn.util.SampleLoader; import com.jsyn.util.WaveRecorder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Play with Granular Synthesis tools. @@ -48,7 +50,9 @@ import com.jsyn.util.WaveRecorder; * @author Phil Burk (C) 2011 Mobileer Inc */ public class PlayGrains extends JApplet { - private static final long serialVersionUID = -8315903842197137926L; + + private static final Logger LOGGER = LoggerFactory.getLogger(PlayGrains.class); + private Synthesizer synth; private LineOut lineOut; private AudioScope scope; @@ -59,13 +63,13 @@ public class PlayGrains extends JApplet { private WaveRecorder recorder; private final static boolean useRecorder = false; - private static final boolean useSample = false; + private static final boolean useSample = true; // If you enable useSample then you will need to replace the file name below with a valid // file name on your computer. - private File sampleFile = new File("/Users/phil/Music/samples/ChewyMonkeysWhistle.aiff"); + private static final File sampleFile = new File("notes_to_tone.wav"); /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { PlayGrains applet = new PlayGrains(); JAppletFrame frame = new JAppletFrame("PlayGrains", applet); frame.setSize(840, 500); @@ -144,7 +148,7 @@ public class PlayGrains extends JApplet { File waveFile = new File("temp_recording.wav"); // Record mono 16 bits. recorder = new WaveRecorder(synth, waveFile, 1); - System.out.println("Writing to WAV file " + waveFile.getAbsolutePath()); + LOGGER.debug("Writing to WAV file " + waveFile.getAbsolutePath()); } if (useSample) { @@ -155,8 +159,7 @@ public class PlayGrains extends JApplet { ramp.output.connect(sampleGrainFarm.position); grainFarm = sampleGrainFarm; } else { - GrainFarm sampleGrainFarm = new GrainFarm(); - grainFarm = sampleGrainFarm; + grainFarm = new GrainFarm(); } synth.add(grainFarm); diff --git a/tests/com/jsyn/examples/PlayMIDI.java b/examples/src/main/java/com/jsyn/examples/PlayMIDI.java index 04c6b9b..92add86 100644 --- a/tests/com/jsyn/examples/PlayMIDI.java +++ b/examples/src/main/java/com/jsyn/examples/PlayMIDI.java @@ -20,22 +20,14 @@ import java.io.IOException; import com.jsyn.JSyn; import com.jsyn.Synthesizer; -import com.jsyn.devices.javasound.MidiDeviceTools; import com.jsyn.instruments.DualOscillatorSynthVoice; -import com.jsyn.instruments.SubtractiveSynthVoice; -import com.jsyn.midi.MessageParser; import com.jsyn.midi.MidiConstants; import com.jsyn.midi.MidiSynthesizer; import com.jsyn.unitgen.LineOut; -import com.jsyn.unitgen.PowerOfTwo; -import com.jsyn.unitgen.SineOscillator; -import com.jsyn.unitgen.UnitOscillator; -import com.jsyn.unitgen.UnitVoice; import com.jsyn.util.MultiChannelSynthesizer; -import com.jsyn.util.VoiceAllocator; import com.jsyn.util.VoiceDescription; -import com.softsynth.math.AudioMath; -import com.softsynth.shared.time.TimeStamp; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Send MIDI messages to JSyn based MIDI synthesizer. @@ -43,6 +35,9 @@ import com.softsynth.shared.time.TimeStamp; * @author Phil Burk (C) 2010 Mobileer Inc */ public class PlayMIDI { + + private static final Logger LOGGER = LoggerFactory.getLogger(PlayMIDI.class); + private static final int NUM_CHANNELS = 16; private static final int VOICES_PER_CHANNEL = 6; private Synthesizer synth; @@ -57,10 +52,8 @@ public class PlayMIDI { try { VoiceDescription description = DualOscillatorSynthVoice.getVoiceDescription(); app.test(description); - System.out.println("Test complete"); - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { + LOGGER.debug("Test complete"); + } catch (IOException | InterruptedException e) { e.printStackTrace(); } System.exit(0); @@ -139,8 +132,7 @@ public class PlayMIDI { // Setup all the channels. int maxChannels = 8; for (int channel = 0; channel < maxChannels; channel++) { - int program = channel; - sendProgramChange(channel, program); + sendProgramChange(channel, channel); } playNotePerChannel(maxChannels); @@ -152,7 +144,7 @@ public class PlayMIDI { float range0 = 12.0f; sendPitchBendRange(0, range0); for(int i = 0; i < 13; i++) { - System.out.println("Bend to pitch " + i); + LOGGER.debug("Bend to pitch " + i); sendPitchBend(0, i / range0); sendNoteOn(0, 60, 100); synth.sleepFor(0.5); @@ -171,7 +163,7 @@ public class PlayMIDI { sendPitchBend(0, 0.0f / range0); // bend by 0 semitones sendPitchBend(1, 1.0f / range1); // bend by 1 semitones - System.out.println("These two notes should play at the same pitch."); + LOGGER.debug("These two notes should play at the same pitch."); sendNoteOn(0, 61, 100); synth.sleepFor(0.5); sendNoteOff(0, 61, 100); @@ -181,7 +173,7 @@ public class PlayMIDI { sendNoteOff(1, 60, 100); synth.sleepFor(2.0); - System.out.println("------ done ---------------"); + LOGGER.debug("------ done ---------------"); } /** diff --git a/tests/com/jsyn/examples/PlayNotes.java b/examples/src/main/java/com/jsyn/examples/PlayNotes.java index 65dc930..636dc1b 100644 --- a/tests/com/jsyn/examples/PlayNotes.java +++ b/examples/src/main/java/com/jsyn/examples/PlayNotes.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,37 +17,36 @@ package com.jsyn.examples; import com.jsyn.JSyn; -import com.jsyn.Synthesizer; import com.jsyn.unitgen.LineOut; import com.jsyn.unitgen.SawtoothOscillator; -import com.jsyn.unitgen.UnitGenerator; -import com.jsyn.unitgen.UnitVoice; import com.softsynth.shared.time.TimeStamp; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Play notes using timestamped noteOn and noteOff methods of the UnitVoice. - * + * * @author Phil Burk (C) 2009 Mobileer Inc */ public class PlayNotes { - Synthesizer synth; - UnitGenerator ugen; - UnitVoice voice; - LineOut lineOut; + + private static final Logger LOGGER = LoggerFactory.getLogger(PlayNotes.class); private void test() { + // Create a context for the synthesizer. - synth = JSyn.createSynthesizer(); + var synth = JSyn.createSynthesizer(); // Set output latency to 123 msec because this is not an interactive app. synth.getAudioDeviceManager().setSuggestedOutputLatency(0.123); // Add a tone generator. - synth.add(ugen = new SawtoothOscillator()); + var voice = new SawtoothOscillator(); + synth.add(voice); // synth.add( ugen = new SineOscillator() ); // synth.add( ugen = new SubtractiveSynthVoice() ); - voice = (UnitVoice) ugen; // Add an output mixer. - synth.add(lineOut = new LineOut()); + var lineOut = new LineOut(); + synth.add(lineOut); // Connect the oscillator to the left and right audio output. voice.getOutput().connect(0, lineOut.input, 0); @@ -86,9 +85,9 @@ public class PlayNotes { // Sleep while the song is being generated in the background thread. try { - System.out.println("Sleep while synthesizing."); + LOGGER.debug("Sleep while synthesizing."); synth.sleepUntil(timeStamp.getTime() + 2.0); - System.out.println("Woke up..."); + LOGGER.debug("Woke up..."); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/tests/com/jsyn/examples/PlayPartials.java b/examples/src/main/java/com/jsyn/examples/PlayPartials.java index 1d7d88e..72e1d7f 100644 --- a/tests/com/jsyn/examples/PlayPartials.java +++ b/examples/src/main/java/com/jsyn/examples/PlayPartials.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,13 +23,18 @@ import com.jsyn.unitgen.LinearRamp; import com.jsyn.unitgen.Multiply; import com.jsyn.unitgen.SineOscillator; import com.jsyn.unitgen.UnitOscillator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Play a enharmonic sine tones using JSyn oscillators. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class PlayPartials { + + private static final Logger LOGGER = LoggerFactory.getLogger(PlayPartials.class); + private Synthesizer synth; private UnitOscillator[] osc; private Multiply[] multipliers; @@ -85,7 +90,7 @@ public class PlayPartials { // oscillator. lineOut.start(); - System.out.println("You should now be hearing a sine wave. ---------"); + LOGGER.debug("You should now be hearing a sine wave. ---------"); // Sleep while the sound is generated in the background. try { @@ -98,13 +103,13 @@ public class PlayPartials { e.printStackTrace(); } - System.out.println("Stop playing. -------------------"); + LOGGER.debug("Stop playing. -------------------"); // Stop everything. synth.stop(); } public static void main(String[] args) { - System.out.println("Java version = " + System.getProperty("java.version")); + LOGGER.debug("Java version = " + System.getProperty("java.version")); new PlayPartials().test(); } } diff --git a/tests/com/jsyn/examples/PlaySample.java b/examples/src/main/java/com/jsyn/examples/PlaySample.java index ac3d5ff..280023e 100644 --- a/tests/com/jsyn/examples/PlaySample.java +++ b/examples/src/main/java/com/jsyn/examples/PlaySample.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,13 +28,18 @@ import com.jsyn.unitgen.VariableRateDataReader; import com.jsyn.unitgen.VariableRateMonoReader; import com.jsyn.unitgen.VariableRateStereoReader; import com.jsyn.util.SampleLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Play a sample from a WAV file using JSyn. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class PlaySample { + + private static final Logger LOGGER = LoggerFactory.getLogger(PlaySample.class); + private Synthesizer synth; private VariableRateDataReader samplePlayer; private LineOut lineOut; @@ -60,11 +65,11 @@ public class PlaySample { // Load the sample and display its properties. SampleLoader.setJavaSoundPreferred(false); sample = SampleLoader.loadFloatSample(sampleFile); - System.out.println("Sample has: channels = " + sample.getChannelsPerFrame()); - System.out.println(" frames = " + sample.getNumFrames()); - System.out.println(" rate = " + sample.getFrameRate()); - System.out.println(" loopStart = " + sample.getSustainBegin()); - System.out.println(" loopEnd = " + sample.getSustainEnd()); + LOGGER.debug("Sample has: channels = " + sample.getChannelsPerFrame()); + LOGGER.debug(" frames = " + sample.getNumFrames()); + LOGGER.debug(" rate = " + sample.getFrameRate()); + LOGGER.debug(" loopStart = " + sample.getSustainBegin()); + LOGGER.debug(" loopEnd = " + sample.getSustainEnd()); if (sample.getChannelsPerFrame() == 1) { synth.add(samplePlayer = new VariableRateMonoReader()); @@ -89,13 +94,13 @@ public class PlaySample { // We can simply queue the entire file. // Or if it has a loop we can play the loop for a while. if (sample.getSustainBegin() < 0) { - System.out.println("queue the sample"); + LOGGER.debug("queue the sample"); samplePlayer.dataQueue.queue(sample); } else { - System.out.println("queueOn the sample"); + LOGGER.debug("queueOn the sample"); samplePlayer.dataQueue.queueOn(sample); synth.sleepFor(8.0); - System.out.println("queueOff the sample"); + LOGGER.debug("queueOff the sample"); samplePlayer.dataQueue.queueOff(sample); } diff --git a/tests/com/jsyn/examples/PlaySampleCrossfade.java b/examples/src/main/java/com/jsyn/examples/PlaySampleCrossfade.java index b5ea5ca..2157039 100644 --- a/tests/com/jsyn/examples/PlaySampleCrossfade.java +++ b/examples/src/main/java/com/jsyn/examples/PlaySampleCrossfade.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,14 +39,19 @@ import com.jsyn.unitgen.VariableRateDataReader; import com.jsyn.unitgen.VariableRateMonoReader; import com.jsyn.unitgen.VariableRateStereoReader; import com.jsyn.util.SampleLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Play a sample from a WAV file using JSyn. Use a crossfade to play a loop at an arbitrary * position. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class PlaySampleCrossfade extends JApplet { + + private static final Logger LOGGER = LoggerFactory.getLogger(PlaySampleCrossfade.class); + private static final double LOOP_START_FRACTION = 0.2; private Synthesizer synth; private VariableRateDataReader samplePlayer; @@ -76,11 +81,11 @@ public class PlaySampleCrossfade extends JApplet { // Load the sample and display its properties. SampleLoader.setJavaSoundPreferred(false); sample = SampleLoader.loadFloatSample(sampleFile); - System.out.println("Sample has: channels = " + sample.getChannelsPerFrame()); - System.out.println(" frames = " + sample.getNumFrames()); - System.out.println(" rate = " + sample.getFrameRate()); - System.out.println(" loopStart = " + sample.getSustainBegin()); - System.out.println(" loopEnd = " + sample.getSustainEnd()); + LOGGER.debug("Sample has: channels = " + sample.getChannelsPerFrame()); + LOGGER.debug(" frames = " + sample.getNumFrames()); + LOGGER.debug(" rate = " + sample.getFrameRate()); + LOGGER.debug(" loopStart = " + sample.getSustainBegin()); + LOGGER.debug(" loopEnd = " + sample.getSustainEnd()); if (sample.getChannelsPerFrame() == 1) { synth.add(samplePlayer = new VariableRateMonoReader()); @@ -149,7 +154,7 @@ public class PlaySampleCrossfade extends JApplet { command.setSkipIfOthers(true); command.setCrossFadeIn(crossFadeSize); - System.out.println("Queue: " + loopStartFrame + ", #" + loopSize + ", X=" + crossFadeSize); + LOGGER.debug("Queue: " + loopStartFrame + ", #" + loopSize + ", X=" + crossFadeSize); synth.queueCommand(command); } @@ -172,7 +177,7 @@ public class PlaySampleCrossfade extends JApplet { } /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { PlaySampleCrossfade applet = new PlaySampleCrossfade(); JAppletFrame frame = new JAppletFrame("PlaySampleCrossfade", applet); frame.setSize(440, 300); diff --git a/tests/com/jsyn/examples/PlaySampleWaveShaper.java b/examples/src/main/java/com/jsyn/examples/PlaySampleWaveShaper.java index 73758dd..3ac320b 100644 --- a/tests/com/jsyn/examples/PlaySampleWaveShaper.java +++ b/examples/src/main/java/com/jsyn/examples/PlaySampleWaveShaper.java @@ -23,11 +23,12 @@ import java.net.URL; import com.jsyn.JSyn; import com.jsyn.Synthesizer; import com.jsyn.data.FloatSample; -import com.jsyn.data.Function; import com.jsyn.unitgen.FunctionEvaluator; import com.jsyn.unitgen.LineOut; import com.jsyn.unitgen.SineOscillator; import com.jsyn.util.SampleLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Play a sample from a WAV file using JSyn. @@ -35,6 +36,9 @@ import com.jsyn.util.SampleLoader; * @author Phil Burk (C) 2010 Mobileer Inc */ public class PlaySampleWaveShaper { + + private static final Logger LOGGER = LoggerFactory.getLogger(PlaySampleWaveShaper.class); + private Synthesizer synth; private LineOut lineOut; @@ -59,21 +63,21 @@ public class PlaySampleWaveShaper { // Load the sample and display its properties. SampleLoader.setJavaSoundPreferred(false); sample = SampleLoader.loadFloatSample(sampleFile); - System.out.println("Sample has: channels = " + sample.getChannelsPerFrame()); - System.out.println(" frames = " + sample.getNumFrames()); - System.out.println(" rate = " + sample.getFrameRate()); - System.out.println(" loopStart = " + sample.getSustainBegin()); - System.out.println(" loopEnd = " + sample.getSustainEnd()); + LOGGER.debug("Sample has: channels = " + sample.getChannelsPerFrame()); + LOGGER.debug(" frames = " + sample.getNumFrames()); + LOGGER.debug(" rate = " + sample.getFrameRate()); + LOGGER.debug(" loopStart = " + sample.getSustainBegin()); + LOGGER.debug(" loopEnd = " + sample.getSustainEnd()); if (sample.getChannelsPerFrame() != 1) { throw new RuntimeException("Can only use mono samples."); } - System.out.println("eval -1.1 = " + sample.evaluate(-1.1)); - System.out.println("eval -1.0 = " + sample.evaluate(-1.0)); - System.out.println("eval 0.3 = " + sample.evaluate(0.3)); - System.out.println("eval 1.0 = " + sample.evaluate(1.0)); - System.out.println("eval 1.1 = " + sample.evaluate(1.1)); + LOGGER.debug("eval -1.1 = " + sample.evaluate(-1.1)); + LOGGER.debug("eval -1.0 = " + sample.evaluate(-1.0)); + LOGGER.debug("eval 0.3 = " + sample.evaluate(0.3)); + LOGGER.debug("eval 1.0 = " + sample.evaluate(1.0)); + LOGGER.debug("eval 1.1 = " + sample.evaluate(1.1)); FunctionEvaluator shaper = new FunctionEvaluator(); shaper.function.set(sample); diff --git a/tests/com/jsyn/examples/PlaySegmentedEnvelope.java b/examples/src/main/java/com/jsyn/examples/PlaySegmentedEnvelope.java index e7cc8f7..b7fb217 100644 --- a/tests/com/jsyn/examples/PlaySegmentedEnvelope.java +++ b/examples/src/main/java/com/jsyn/examples/PlaySegmentedEnvelope.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,13 +28,18 @@ import com.jsyn.unitgen.UnitOscillator; import com.jsyn.unitgen.VariableRateDataReader; import com.jsyn.unitgen.VariableRateMonoReader; import com.jsyn.util.WaveRecorder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Modulate the amplitude of an oscillator using a segmented envelope. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class PlaySegmentedEnvelope { + + private static final Logger LOGGER = LoggerFactory.getLogger(PlaySegmentedEnvelope.class); + private Synthesizer synth; private UnitOscillator osc; private LineOut lineOut; @@ -55,7 +60,7 @@ public class PlaySegmentedEnvelope { File waveFile = new File("temp_recording.wav"); // Default is stereo, 16 bits. recorder = new WaveRecorder(synth, waveFile); - System.out.println("Writing to WAV file " + waveFile.getAbsolutePath()); + LOGGER.debug("Writing to WAV file " + waveFile.getAbsolutePath()); } // Create an envelope consisting of (duration,value) pairs. diff --git a/tests/com/jsyn/examples/PlaySegmentedEnvelopeCallback.java b/examples/src/main/java/com/jsyn/examples/PlaySegmentedEnvelopeCallback.java index cf2441e..d8f4ff3 100644 --- a/tests/com/jsyn/examples/PlaySegmentedEnvelopeCallback.java +++ b/examples/src/main/java/com/jsyn/examples/PlaySegmentedEnvelopeCallback.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,14 +27,19 @@ import com.jsyn.unitgen.SawtoothOscillatorBL; import com.jsyn.unitgen.UnitOscillator; import com.jsyn.unitgen.VariableRateDataReader; import com.jsyn.unitgen.VariableRateMonoReader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Use a UnitDataQueueCallback to notify us of the envelope's progress. Modulate the amplitude of an * oscillator using a segmented envelope. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class PlaySegmentedEnvelopeCallback { + + private static final Logger LOGGER = LoggerFactory.getLogger(PlaySegmentedEnvelopeCallback.class); + private Synthesizer synth; private UnitOscillator osc; private LineOut lineOut; @@ -90,17 +95,17 @@ public class PlaySegmentedEnvelopeCallback { class TestQueueCallback implements UnitDataQueueCallback { @Override public void started(QueueDataEvent event) { - System.out.println("CALLBACK: Envelope started."); + LOGGER.debug("CALLBACK: Envelope started."); } @Override public void looped(QueueDataEvent event) { - System.out.println("CALLBACK: Envelope looped."); + LOGGER.debug("CALLBACK: Envelope looped."); } @Override public void finished(QueueDataEvent event) { - System.out.println("CALLBACK: Envelope finished."); + LOGGER.debug("CALLBACK: Envelope finished."); // Queue the envelope again at a faster rate. // (If this hangs we may have hit a deadlock.) envelopePlayer.rate.set(2.0); diff --git a/tests/com/jsyn/examples/PlaySequence.java b/examples/src/main/java/com/jsyn/examples/PlaySequence.java index 9d058b2..9d058b2 100644 --- a/tests/com/jsyn/examples/PlaySequence.java +++ b/examples/src/main/java/com/jsyn/examples/PlaySequence.java diff --git a/tests/com/jsyn/examples/PlayTone.java b/examples/src/main/java/com/jsyn/examples/PlayTone.java index 172c98a..e514dba 100644 --- a/tests/com/jsyn/examples/PlayTone.java +++ b/examples/src/main/java/com/jsyn/examples/PlayTone.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,59 +17,60 @@ package com.jsyn.examples; import com.jsyn.JSyn; -import com.jsyn.Synthesizer; import com.jsyn.unitgen.LineOut; import com.jsyn.unitgen.SineOscillator; -import com.jsyn.unitgen.UnitOscillator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Play a tone using a JSyn oscillator. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class PlayTone { - Synthesizer synth; - UnitOscillator osc; - LineOut lineOut; + + private static final Logger LOGGER = LoggerFactory.getLogger(PlayTone.class); private void test() { // Create a context for the synthesizer. - synth = JSyn.createSynthesizer(); + var synth = JSyn.createSynthesizer(); // Start synthesizer using default stereo output at 44100 Hz. synth.start(); // Add a tone generator. - synth.add(osc = new SineOscillator()); + var oscillator = new SineOscillator(); + synth.add(oscillator); // Add a stereo audio output unit. - synth.add(lineOut = new LineOut()); + var lineOut = new LineOut(); + synth.add(lineOut); // Connect the oscillator to both channels of the output. - osc.output.connect(0, lineOut.input, 0); - osc.output.connect(0, lineOut.input, 1); + oscillator.output.connect(0, lineOut.input, 0); + oscillator.output.connect(0, lineOut.input, 1); // Set the frequency and amplitude for the sine wave. - osc.frequency.set(345.0); - osc.amplitude.set(0.6); + oscillator.frequency.set(345.0); + oscillator.amplitude.set(0.6); // We only need to start the LineOut. It will pull data from the // oscillator. lineOut.start(); - System.out.println("You should now be hearing a sine wave. ---------"); + LOGGER.debug("You should now be hearing a sine wave. ---------"); // Sleep while the sound is generated in the background. try { double time = synth.getCurrentTime(); - System.out.println("time = " + time); + LOGGER.debug("time = " + time); // Sleep for a few seconds. synth.sleepUntil(time + 4.0); } catch (InterruptedException e) { e.printStackTrace(); } - System.out.println("Stop playing. -------------------"); + LOGGER.debug("Stop playing. -------------------"); // Stop everything. synth.stop(); } diff --git a/tests/com/jsyn/examples/RecordSineSweep.java b/examples/src/main/java/com/jsyn/examples/RecordSineSweep.java index bb248e8..13161c6 100644 --- a/tests/com/jsyn/examples/RecordSineSweep.java +++ b/examples/src/main/java/com/jsyn/examples/RecordSineSweep.java @@ -4,16 +4,16 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -/** +/** * Test recording to disk in non-real-time. * Play several frequencies of a sine wave. * Save data in a WAV file format. @@ -34,8 +34,13 @@ import com.jsyn.unitgen.SawtoothOscillatorBL; import com.jsyn.unitgen.SineOscillator; import com.jsyn.unitgen.UnitOscillator; import com.jsyn.util.WaveRecorder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RecordSineSweep { + + private static final Logger LOGGER = LoggerFactory.getLogger(RecordSineSweep.class); + final static double SONG_DURATION = 4.0; private Synthesizer synth; private UnitOscillator leftOsc; @@ -54,7 +59,7 @@ public class RecordSineSweep { File waveFile = new File("temp_recording.wav"); // Default is stereo, 16 bits. recorder = new WaveRecorder(synth, waveFile); - System.out.println("Writing to WAV file " + waveFile.getAbsolutePath()); + LOGGER.debug("Writing to WAV file " + waveFile.getAbsolutePath()); } // Add some tone generators. synth.add(leftOsc = new SineOscillator()); @@ -101,7 +106,7 @@ public class RecordSineSweep { // Test stopping and restarting a recorder. This will cause a pop. if (recorder != null) { - System.out.println("Stop and restart recorder."); + LOGGER.debug("Stop and restart recorder."); recorder.stop(); } sweeper.input.set(100.0); diff --git a/tests/com/jsyn/examples/SampleHoldNoteBlaster.java b/examples/src/main/java/com/jsyn/examples/SampleHoldNoteBlaster.java index bc6b4d0..bc6b4d0 100644 --- a/tests/com/jsyn/examples/SampleHoldNoteBlaster.java +++ b/examples/src/main/java/com/jsyn/examples/SampleHoldNoteBlaster.java diff --git a/tests/com/jsyn/examples/SawFaders.java b/examples/src/main/java/com/jsyn/examples/SawFaders.java index eaa3d1b..f7ce555 100644 --- a/tests/com/jsyn/examples/SawFaders.java +++ b/examples/src/main/java/com/jsyn/examples/SawFaders.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,11 +35,10 @@ import com.jsyn.unitgen.UnitOscillator; /** * Play a sawtooth using a JSyn oscillator and some knobs. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class SawFaders extends JApplet { - private static final long serialVersionUID = -2704222221111608377L; private Synthesizer synth; private UnitOscillator osc; private LinearRamp lag; @@ -93,7 +92,7 @@ public class SawFaders extends JApplet { } /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { SawFaders applet = new SawFaders(); JAppletFrame frame = new JAppletFrame("SawFaders", applet); frame.setSize(440, 200); diff --git a/tests/com/jsyn/examples/SeeGoogleWave.java b/examples/src/main/java/com/jsyn/examples/SeeGoogleWave.java index eb7a5ff..ff41e25 100644 --- a/tests/com/jsyn/examples/SeeGoogleWave.java +++ b/examples/src/main/java/com/jsyn/examples/SeeGoogleWave.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,18 +32,17 @@ import com.jsyn.unitgen.LineOut; /** * Generate the waveform shown on the Google home page on 2/22/12. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class SeeGoogleWave extends JApplet { - private static final long serialVersionUID = -831590388347137926L; private Synthesizer synth; private GoogleWaveOscillator googleWaveUnit; private LineOut lineOut; private AudioScope scope; /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { SeeGoogleWave applet = new SeeGoogleWave(); JAppletFrame frame = new JAppletFrame("Google Wave", applet); frame.setSize(640, 500); diff --git a/tests/com/jsyn/examples/SeeOscillators.java b/examples/src/main/java/com/jsyn/examples/SeeOscillators.java index b8088c4..8cdc3b8 100644 --- a/tests/com/jsyn/examples/SeeOscillators.java +++ b/examples/src/main/java/com/jsyn/examples/SeeOscillators.java @@ -60,7 +60,6 @@ import com.jsyn.unitgen.UnitOscillator; * @author Phil Burk (C) 2010 Mobileer Inc */ public class SeeOscillators extends JApplet { - private static final long serialVersionUID = -8315903842197137926L; private Synthesizer synth; private ArrayList<UnitOscillator> oscillators = new ArrayList<UnitOscillator>(); private LineOut lineOut; @@ -75,7 +74,7 @@ public class SeeOscillators extends JApplet { private DoubleBoundedRangeSlider shapeSlider; /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { SeeOscillators applet = new SeeOscillators(); JAppletFrame frame = new JAppletFrame("ShowWaves", applet); frame.setSize(640, 500); diff --git a/tests/com/jsyn/examples/ShowWaves.java b/examples/src/main/java/com/jsyn/examples/ShowWaves.java index b1dd215..8ad3c4a 100644 --- a/tests/com/jsyn/examples/ShowWaves.java +++ b/examples/src/main/java/com/jsyn/examples/ShowWaves.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,11 +35,10 @@ import com.jsyn.unitgen.UnitOscillator; /** * Display waveforms using the AudioScope. The frequency of the oscillators is modulated by an LFO. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class ShowWaves extends JApplet { - private static final long serialVersionUID = -8315903842197137926L; private Synthesizer synth; private UnitOscillator lfo; private Add adder; @@ -48,7 +47,7 @@ public class ShowWaves extends JApplet { private AudioScope scope; /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { ShowWaves applet = new ShowWaves(); JAppletFrame frame = new JAppletFrame("ShowWaves", applet); frame.setSize(640, 300); diff --git a/tests/com/jsyn/examples/SwarmOfOscillators.java b/examples/src/main/java/com/jsyn/examples/SwarmOfOscillators.java index 9f7c19c..9f7c19c 100644 --- a/tests/com/jsyn/examples/SwarmOfOscillators.java +++ b/examples/src/main/java/com/jsyn/examples/SwarmOfOscillators.java diff --git a/tests/com/jsyn/examples/UseMidiKeyboard.java b/examples/src/main/java/com/jsyn/examples/UseMidiKeyboard.java index 0efa039..f88b877 100644 --- a/tests/com/jsyn/examples/UseMidiKeyboard.java +++ b/examples/src/main/java/com/jsyn/examples/UseMidiKeyboard.java @@ -31,6 +31,8 @@ import com.jsyn.midi.MidiSynthesizer; import com.jsyn.unitgen.LineOut; import com.jsyn.util.MultiChannelSynthesizer; import com.jsyn.util.VoiceDescription; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Connect a USB MIDI Keyboard to the internal MIDI Synthesizer using JavaSound. @@ -38,6 +40,8 @@ import com.jsyn.util.VoiceDescription; * @author Phil Burk (C) 2010 Mobileer Inc */ public class UseMidiKeyboard { + + private static final Logger LOGGER = LoggerFactory.getLogger(UseMidiKeyboard.class); private static final int NUM_CHANNELS = 16; private static final int VOICES_PER_CHANNEL = 3; @@ -87,10 +91,10 @@ public class UseMidiKeyboard { // Put the receiver in the transmitter. // This gives fairly low latency playing. keyboard.getTransmitter().setReceiver(receiver); - System.out.println("Play MIDI keyboard: " + keyboard.getDeviceInfo().getDescription()); + LOGGER.debug("Play MIDI keyboard: " + keyboard.getDeviceInfo().getDescription()); result = 0; } else { - System.out.println("Could not find a keyboard."); + LOGGER.debug("Could not find a keyboard."); } return result; } diff --git a/tests/com/jsyn/examples/WindCircuit.java b/examples/src/main/java/com/jsyn/examples/WindCircuit.java index 1e3623e..1e3623e 100644 --- a/tests/com/jsyn/examples/WindCircuit.java +++ b/examples/src/main/java/com/jsyn/examples/WindCircuit.java diff --git a/examples/src/main/resources/log4j.xml b/examples/src/main/resources/log4j.xml new file mode 100644 index 0000000..cc107b1 --- /dev/null +++ b/examples/src/main/resources/log4j.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" > +<log4j:configuration debug="false"> + <appender name="default.console" class="org.apache.log4j.ConsoleAppender"> + <param name="target" value="System.out"/> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="[%d{HH:mm:ss}] [%t/%p]: %m%n"/> + </layout> + </appender> + + <root> + <priority value="INFO" /> + <appender-ref ref="default.console"/> + </root> +</log4j:configuration> diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 0000000..5c2d1cf --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..bb8b2fc --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists @@ -0,0 +1,188 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..9618d8d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,100 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..94bd48c --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'jysn' +include 'examples' diff --git a/src/com/jsyn/JSyn.java b/src/main/java/com/jsyn/JSyn.java index bbc2891..bbc2891 100644 --- a/src/com/jsyn/JSyn.java +++ b/src/main/java/com/jsyn/JSyn.java diff --git a/src/com/jsyn/Synthesizer.java b/src/main/java/com/jsyn/Synthesizer.java index bfabb4c..bfabb4c 100644 --- a/src/com/jsyn/Synthesizer.java +++ b/src/main/java/com/jsyn/Synthesizer.java diff --git a/src/com/jsyn/apps/AboutJSyn.java b/src/main/java/com/jsyn/apps/AboutJSyn.java index e6c1fbd..0624591 100644 --- a/src/com/jsyn/apps/AboutJSyn.java +++ b/src/main/java/com/jsyn/apps/AboutJSyn.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,7 +35,7 @@ import com.jsyn.unitgen.UnitOscillator; /** * Show the version of JSyn and play some sine waves. This program will be run if you double click * the JSyn jar file. - * + * * @author Phil Burk (C) 2011 Mobileer Inc */ public class AboutJSyn extends JApplet { @@ -103,7 +103,7 @@ public class AboutJSyn extends JApplet { } /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { AboutJSyn applet = new AboutJSyn(); JAppletFrame frame = new JAppletFrame("About JSyn", applet); frame.setSize(440, 300); diff --git a/src/com/jsyn/apps/InstrumentTester.java b/src/main/java/com/jsyn/apps/InstrumentTester.java index 6e347cd..2505759 100644 --- a/src/com/jsyn/apps/InstrumentTester.java +++ b/src/main/java/com/jsyn/apps/InstrumentTester.java @@ -41,6 +41,8 @@ import com.jsyn.util.PolyphonicInstrument; import com.jsyn.util.VoiceDescription; import com.softsynth.math.AudioMath; import com.softsynth.shared.time.TimeStamp; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Let the user select an instrument using the InstrumentBrowser and play @@ -50,7 +52,10 @@ import com.softsynth.shared.time.TimeStamp; * @author Phil Burk (C) 2012 Mobileer Inc */ public class InstrumentTester extends JApplet { + + private static final Logger LOGGER = LoggerFactory.getLogger(InstrumentTester.class); private static final long serialVersionUID = -2704222221111608377L; + private Synthesizer synth; private LineOut lineOut; private SoundTweaker tweaker; @@ -105,10 +110,10 @@ public class InstrumentTester extends JApplet { // Put the receiver in the transmitter. // This gives fairly low latency playing. keyboard.getTransmitter().setReceiver(receiver); - System.out.println("Play MIDI keyboard: " + keyboard.getDeviceInfo().getDescription()); + LOGGER.debug("Play MIDI keyboard: " + keyboard.getDeviceInfo().getDescription()); result = 0; } else { - System.out.println("Could not find a keyboard."); + LOGGER.debug("Could not find a keyboard."); } return result; } @@ -194,7 +199,7 @@ public class InstrumentTester extends JApplet { } /* Can be run as either an application or as an applet. */ - public static void main(String args[]) { + public static void main(String[] args) { InstrumentTester applet = new InstrumentTester(); JAppletFrame frame = new JAppletFrame("InstrumentTester", applet); frame.setSize(600, 800); diff --git a/src/com/jsyn/data/AudioSample.java b/src/main/java/com/jsyn/data/AudioSample.java index dcbbae5..dcbbae5 100644 --- a/src/com/jsyn/data/AudioSample.java +++ b/src/main/java/com/jsyn/data/AudioSample.java diff --git a/src/com/jsyn/data/DoubleTable.java b/src/main/java/com/jsyn/data/DoubleTable.java index ca64c94..ca64c94 100644 --- a/src/com/jsyn/data/DoubleTable.java +++ b/src/main/java/com/jsyn/data/DoubleTable.java diff --git a/src/com/jsyn/data/FloatSample.java b/src/main/java/com/jsyn/data/FloatSample.java index 2d8c973..2d8c973 100644 --- a/src/com/jsyn/data/FloatSample.java +++ b/src/main/java/com/jsyn/data/FloatSample.java diff --git a/src/com/jsyn/data/Function.java b/src/main/java/com/jsyn/data/Function.java index c0e6566..c0e6566 100644 --- a/src/com/jsyn/data/Function.java +++ b/src/main/java/com/jsyn/data/Function.java diff --git a/src/com/jsyn/data/HammingWindow.java b/src/main/java/com/jsyn/data/HammingWindow.java index d8e1238..d8e1238 100644 --- a/src/com/jsyn/data/HammingWindow.java +++ b/src/main/java/com/jsyn/data/HammingWindow.java diff --git a/src/com/jsyn/data/HannWindow.java b/src/main/java/com/jsyn/data/HannWindow.java index 878d07c..878d07c 100644 --- a/src/com/jsyn/data/HannWindow.java +++ b/src/main/java/com/jsyn/data/HannWindow.java diff --git a/src/com/jsyn/data/SampleMarker.java b/src/main/java/com/jsyn/data/SampleMarker.java index d3db1d4..d3db1d4 100644 --- a/src/com/jsyn/data/SampleMarker.java +++ b/src/main/java/com/jsyn/data/SampleMarker.java diff --git a/src/com/jsyn/data/SegmentedEnvelope.java b/src/main/java/com/jsyn/data/SegmentedEnvelope.java index efdfd89..efdfd89 100644 --- a/src/com/jsyn/data/SegmentedEnvelope.java +++ b/src/main/java/com/jsyn/data/SegmentedEnvelope.java diff --git a/src/com/jsyn/data/SequentialData.java b/src/main/java/com/jsyn/data/SequentialData.java index 0deb5c9..f567493 100644 --- a/src/com/jsyn/data/SequentialData.java +++ b/src/main/java/com/jsyn/data/SequentialData.java @@ -49,7 +49,6 @@ public interface SequentialData { * * @param index sample index is ((frameIndex * channelsPerFrame) + channelIndex) */ - double readDouble(int index); /*** diff --git a/src/com/jsyn/data/SequentialDataCommon.java b/src/main/java/com/jsyn/data/SequentialDataCommon.java index 5cc51df..5cc51df 100644 --- a/src/com/jsyn/data/SequentialDataCommon.java +++ b/src/main/java/com/jsyn/data/SequentialDataCommon.java diff --git a/src/com/jsyn/data/ShortSample.java b/src/main/java/com/jsyn/data/ShortSample.java index 4a4110e..4a4110e 100644 --- a/src/com/jsyn/data/ShortSample.java +++ b/src/main/java/com/jsyn/data/ShortSample.java diff --git a/src/com/jsyn/data/SpectralWindow.java b/src/main/java/com/jsyn/data/SpectralWindow.java index 0fcfac4..0fcfac4 100644 --- a/src/com/jsyn/data/SpectralWindow.java +++ b/src/main/java/com/jsyn/data/SpectralWindow.java diff --git a/src/com/jsyn/data/SpectralWindowFactory.java b/src/main/java/com/jsyn/data/SpectralWindowFactory.java index 01cced6..01cced6 100644 --- a/src/com/jsyn/data/SpectralWindowFactory.java +++ b/src/main/java/com/jsyn/data/SpectralWindowFactory.java diff --git a/src/com/jsyn/data/Spectrum.java b/src/main/java/com/jsyn/data/Spectrum.java index 66e4ee4..66e4ee4 100644 --- a/src/com/jsyn/data/Spectrum.java +++ b/src/main/java/com/jsyn/data/Spectrum.java diff --git a/src/com/jsyn/devices/AudioDeviceFactory.java b/src/main/java/com/jsyn/devices/AudioDeviceFactory.java index 612c81d..612c81d 100644 --- a/src/com/jsyn/devices/AudioDeviceFactory.java +++ b/src/main/java/com/jsyn/devices/AudioDeviceFactory.java diff --git a/src/com/jsyn/devices/AudioDeviceInputStream.java b/src/main/java/com/jsyn/devices/AudioDeviceInputStream.java index a3d1854..a3d1854 100644 --- a/src/com/jsyn/devices/AudioDeviceInputStream.java +++ b/src/main/java/com/jsyn/devices/AudioDeviceInputStream.java diff --git a/src/com/jsyn/devices/AudioDeviceManager.java b/src/main/java/com/jsyn/devices/AudioDeviceManager.java index ac8d47c..ac8d47c 100644 --- a/src/com/jsyn/devices/AudioDeviceManager.java +++ b/src/main/java/com/jsyn/devices/AudioDeviceManager.java diff --git a/src/com/jsyn/devices/AudioDeviceOutputStream.java b/src/main/java/com/jsyn/devices/AudioDeviceOutputStream.java index 5c17efb..5c17efb 100644 --- a/src/com/jsyn/devices/AudioDeviceOutputStream.java +++ b/src/main/java/com/jsyn/devices/AudioDeviceOutputStream.java diff --git a/src/com/jsyn/devices/javasound/JavaSoundAudioDevice.java b/src/main/java/com/jsyn/devices/javasound/JavaSoundAudioDevice.java index 656dc1c..75c4a8a 100644 --- a/src/com/jsyn/devices/javasound/JavaSoundAudioDevice.java +++ b/src/main/java/com/jsyn/devices/javasound/JavaSoundAudioDevice.java @@ -17,7 +17,6 @@ package com.jsyn.devices.javasound; import java.util.ArrayList; -import java.util.logging.Logger; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; @@ -31,6 +30,8 @@ import javax.sound.sampled.TargetDataLine; import com.jsyn.devices.AudioDeviceInputStream; import com.jsyn.devices.AudioDeviceManager; import com.jsyn.devices.AudioDeviceOutputStream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Use JavaSound to access the audio hardware. @@ -38,6 +39,9 @@ import com.jsyn.devices.AudioDeviceOutputStream; * @author Phil Burk (C) 2009 Mobileer Inc */ public class JavaSoundAudioDevice implements AudioDeviceManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(JavaSoundAudioDevice.class); + private static final int BYTES_PER_SAMPLE = 2; private static final boolean USE_BIG_ENDIAN = false; @@ -47,13 +51,11 @@ public class JavaSoundAudioDevice implements AudioDeviceManager { private int defaultInputDeviceID = -1; private int defaultOutputDeviceID = -1; - static Logger logger = Logger.getLogger(JavaSoundAudioDevice.class.getName()); - public JavaSoundAudioDevice() { String osName = System.getProperty("os.name"); if (osName.contains("Windows")) { suggestedOutputLatency = 0.08; - logger.info("JSyn: default output latency set to " + LOGGER.info("JSyn: default output latency set to " + ((int) (suggestedOutputLatency * 1000)) + " msec for " + osName); } deviceRecords = new ArrayList<DeviceInfo>(); @@ -63,7 +65,7 @@ public class JavaSoundAudioDevice implements AudioDeviceManager { private void dumpAvailableMixers() { for (DeviceInfo deviceInfo : deviceRecords) { - logger.fine("" + deviceInfo); + LOGGER.debug("" + deviceInfo); } } @@ -120,7 +122,7 @@ public class JavaSoundAudioDevice implements AudioDeviceManager { return maxChannels; } - class DeviceInfo { + static class DeviceInfo { String name; int maxInputs; int maxOutputs; @@ -131,7 +133,7 @@ public class JavaSoundAudioDevice implements AudioDeviceManager { } } - private class JavaSoundStream { + private static class JavaSoundStream { AudioFormat format; byte[] bytes; int frameRate; @@ -159,8 +161,7 @@ public class JavaSoundAudioDevice implements AudioDeviceManager { int calculateBufferSize(double suggestedOutputLatency) { int numFrames = (int) (suggestedOutputLatency * frameRate); - int numBytes = numFrames * samplesPerFrame * BYTES_PER_SAMPLE; - return numBytes; + return numFrames * samplesPerFrame * BYTES_PER_SAMPLE; } } @@ -177,13 +178,13 @@ public class JavaSoundAudioDevice implements AudioDeviceManager { DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); if (!AudioSystem.isLineSupported(info)) { // Handle the error. - logger.severe("JavaSoundOutputStream - not supported." + format); + LOGGER.error("JavaSoundOutputStream - not supported." + format); } else { try { line = (SourceDataLine) getDataLine(info); int bufferSize = calculateBufferSize(suggestedOutputLatency); line.open(format, bufferSize); - logger.fine("Output buffer size = " + bufferSize + " bytes."); + LOGGER.debug("Output buffer size = " + bufferSize + " bytes."); line.start(); } catch (Exception e) { @@ -273,13 +274,13 @@ public class JavaSoundAudioDevice implements AudioDeviceManager { DataLine.Info info = new DataLine.Info(TargetDataLine.class, format); if (!AudioSystem.isLineSupported(info)) { // Handle the error. - logger.severe("JavaSoundInputStream - not supported." + format); + LOGGER.error("JavaSoundInputStream - not supported." + format); } else { try { line = (TargetDataLine) getDataLine(info); int bufferSize = calculateBufferSize(suggestedInputLatency); line.open(format, bufferSize); - logger.fine("Input buffer size = " + bufferSize + " bytes."); + LOGGER.debug("Input buffer size = " + bufferSize + " bytes."); line.start(); } catch (Exception e) { e.printStackTrace(); diff --git a/src/com/jsyn/devices/javasound/MidiDeviceTools.java b/src/main/java/com/jsyn/devices/javasound/MidiDeviceTools.java index 413beca..9cff095 100644 --- a/src/com/jsyn/devices/javasound/MidiDeviceTools.java +++ b/src/main/java/com/jsyn/devices/javasound/MidiDeviceTools.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,6 +16,9 @@ package com.jsyn.devices.javasound; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import javax.sound.midi.MidiDevice; import javax.sound.midi.MidiSystem; import javax.sound.midi.MidiUnavailableException; @@ -23,18 +26,21 @@ import javax.sound.midi.Sequencer; import javax.sound.midi.Synthesizer; public class MidiDeviceTools { + + private static final Logger LOGGER = LoggerFactory.getLogger(MidiDeviceTools.class); + /** Print the available MIDI Devices. */ public static void listDevices() { // Ask the MidiSystem what is available. MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo(); // Print info about each device. for (MidiDevice.Info info : infos) { - System.out.println("MIDI Info: " + info.getDescription() + ", " + info.getName() + ", " + LOGGER.debug("MIDI Info: " + info.getDescription() + ", " + info.getName() + ", " + info.getVendor() + ", " + info.getVersion()); // Get the device for more information. try { MidiDevice device = MidiSystem.getMidiDevice(info); - System.out.println(" Device: " + ", #recv = " + device.getMaxReceivers() + LOGGER.debug(" Device: " + ", #recv = " + device.getMaxReceivers() + ", #xmit = " + device.getMaxTransmitters() + ", open = " + device.isOpen() + ", " + device); } catch (MidiUnavailableException e) { @@ -61,7 +67,7 @@ public class MidiDeviceTools { || (info.getDescription().toLowerCase() .contains(text.toLowerCase()))) { keyboard = device; - System.out.println("Chose: " + info.getDescription()); + LOGGER.debug("Chose: " + info.getDescription()); break; } } diff --git a/src/com/jsyn/devices/jportaudio/JPortAudioDevice.java b/src/main/java/com/jsyn/devices/jportaudio/JPortAudioDevice.java index a8e574a..15ab9ed 100644 --- a/src/com/jsyn/devices/jportaudio/JPortAudioDevice.java +++ b/src/main/java/com/jsyn/devices/jportaudio/JPortAudioDevice.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,8 +24,13 @@ import com.portaudio.DeviceInfo; import com.portaudio.HostApiInfo; import com.portaudio.PortAudio; import com.portaudio.StreamParameters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class JPortAudioDevice implements AudioDeviceManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(JPortAudioDevice.class); + private double suggestedOutputLatency = 0.030; private double suggestedInputLatency = 0.050; private static final int FRAMES_PER_BUFFER = 128; @@ -129,7 +134,7 @@ public class JPortAudioDevice implements AudioDeviceManager { return new JPAInputStream(deviceID, frameRate, samplesPerFrame); } - private class JPAStream { + private static class JPAStream { BlockingStream blockingStream; float[] floatBuffer = null; int samplesPerFrame; @@ -160,7 +165,7 @@ public class JPortAudioDevice implements AudioDeviceManager { streamParameters.device = deviceID; streamParameters.suggestedLatency = suggestedOutputLatency; int flags = 0; - System.out.println("Audio output on " + getDeviceName(deviceID)); + LOGGER.debug("Audio output on " + getDeviceName(deviceID)); blockingStream = PortAudio.openStream(null, streamParameters, frameRate, FRAMES_PER_BUFFER, flags); } @@ -208,7 +213,7 @@ public class JPortAudioDevice implements AudioDeviceManager { streamParameters.device = deviceID; streamParameters.suggestedLatency = suggestedInputLatency; int flags = 0; - System.out.println("Audio input from " + getDeviceName(deviceID)); + LOGGER.debug("Audio input from " + getDeviceName(deviceID)); blockingStream = PortAudio.openStream(streamParameters, null, frameRate, FRAMES_PER_BUFFER, flags); } diff --git a/src/com/jsyn/engine/LoadAnalyzer.java b/src/main/java/com/jsyn/engine/LoadAnalyzer.java index cbf7ed5..cbf7ed5 100644 --- a/src/com/jsyn/engine/LoadAnalyzer.java +++ b/src/main/java/com/jsyn/engine/LoadAnalyzer.java diff --git a/src/com/jsyn/engine/MultiTable.java b/src/main/java/com/jsyn/engine/MultiTable.java index 6606639..6606639 100644 --- a/src/com/jsyn/engine/MultiTable.java +++ b/src/main/java/com/jsyn/engine/MultiTable.java diff --git a/src/com/jsyn/engine/SynthesisEngine.java b/src/main/java/com/jsyn/engine/SynthesisEngine.java index b49e78e..30872a8 100644 --- a/src/com/jsyn/engine/SynthesisEngine.java +++ b/src/main/java/com/jsyn/engine/SynthesisEngine.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.List; import java.util.ListIterator; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.logging.Logger; import com.jsyn.JSyn; import com.jsyn.Synthesizer; @@ -32,6 +31,8 @@ import com.jsyn.unitgen.UnitGenerator; import com.softsynth.shared.time.ScheduledCommand; import com.softsynth.shared.time.ScheduledQueue; import com.softsynth.shared.time.TimeStamp; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; //TODO Resolve problem with HearDAHDSR where "Rate" port.set is not reflected in knob. Engine not running. //TODO new tutorial and docs on website @@ -53,6 +54,9 @@ import com.softsynth.shared.time.TimeStamp; * @see Synthesizer */ public class SynthesisEngine implements Synthesizer { + + private static final Logger LOGGER = LoggerFactory.getLogger(SynthesisEngine.class); + private final static int BLOCKS_PER_BUFFER = 8; private final static int FRAMES_PER_BUFFER = Synthesizer.FRAMES_PER_BLOCK * BLOCKS_PER_BUFFER; // I have measured JavaSound taking 1200 msec to close devices. @@ -92,8 +96,6 @@ public class SynthesisEngine implements Synthesizer { /** A fraction that is approximately -90.3 dB. Defined as 1 bit of an S16. */ public static final double DB90 = (1.0 / (1 << 15)); - static Logger logger = Logger.getLogger(SynthesisEngine.class.getName()); - public SynthesisEngine(AudioDeviceManager audioDeviceManager) { this.audioDeviceManager = audioDeviceManager; } @@ -185,7 +187,7 @@ public class SynthesisEngine implements Synthesizer { } } - class ChannelBlockBuffer { + static class ChannelBlockBuffer { private final double[] values; ChannelBlockBuffer(int framesPerBlock) { @@ -215,7 +217,7 @@ public class SynthesisEngine implements Synthesizer { public synchronized void start(int frameRate, int inputDeviceID, int numInputChannels, int outputDeviceID, int numOutputChannels) { if (started) { - logger.info("JSyn already started."); + LOGGER.info("JSyn already started."); return; } @@ -224,7 +226,7 @@ public class SynthesisEngine implements Synthesizer { setupAudioBuffers(numInputChannels, numOutputChannels); - logger.info("Pure Java JSyn from www.softsynth.com, rate = " + frameRate + ", " + LOGGER.info("Pure Java JSyn from www.softsynth.com, rate = " + frameRate + ", " + (useRealTime ? "RT" : "NON-RealTime") + ", " + JSyn.VERSION_TEXT); inverseNyquist = 2.0 / frameRate; @@ -232,11 +234,11 @@ public class SynthesisEngine implements Synthesizer { if (useRealTime) { engineThread = new EngineThread(inputDeviceID, numInputChannels, outputDeviceID, numOutputChannels); - logger.fine("Synth thread old priority = " + engineThread.getPriority()); + LOGGER.debug("Synth thread old priority = " + engineThread.getPriority()); int engineThreadPriority = engineThread.getPriority() + 2 > Thread.MAX_PRIORITY ? Thread.MAX_PRIORITY : engineThread.getPriority() + 2; engineThread.setPriority(engineThreadPriority); - logger.fine("Synth thread new priority = " + engineThread.getPriority()); + LOGGER.debug("Synth thread new priority = " + engineThread.getPriority()); engineThread.start(); } @@ -252,7 +254,7 @@ public class SynthesisEngine implements Synthesizer { @Override public synchronized void stop() { if (!started) { - logger.info("JSyn already stopped."); + LOGGER.info("JSyn already stopped."); return; } @@ -299,23 +301,23 @@ public class SynthesisEngine implements Synthesizer { @Override public void run() { - logger.fine("JSyn synthesis thread starting."); + LOGGER.debug("JSyn synthesis thread starting."); try { if (audioInputStream != null) { - logger.finer("JSyn synthesis thread trying to start audio INPUT!"); + LOGGER.debug("JSyn synthesis thread trying to start audio INPUT!"); audioInputStream.start(); mInputLatency = audioInputStream.getLatency(); String msg = String.format("Input Latency in = %5.1f msec", 1000 * mInputLatency); - logger.fine(msg); + LOGGER.debug(msg); } if (audioOutputStream != null) { - logger.finer("JSyn synthesis thread trying to start audio OUTPUT!"); + LOGGER.debug("JSyn synthesis thread trying to start audio OUTPUT!"); audioOutputStream.start(); mOutputLatency = audioOutputStream.getLatency(); String msg = String.format("Output Latency = %5.1f msec", 1000 * mOutputLatency); - logger.fine(msg); + LOGGER.debug(msg); // Buy some time while we fill the buffer. audioOutputStream.write(outputBuffer.interleavedBuffer); } @@ -348,7 +350,7 @@ public class SynthesisEngine implements Synthesizer { go = false; } finally { - logger.info("JSyn synthesis thread in finally code."); + LOGGER.info("JSyn synthesis thread in finally code."); // Stop audio system. if (audioInputStream != null) { audioInputStream.stop(); @@ -357,7 +359,7 @@ public class SynthesisEngine implements Synthesizer { audioOutputStream.stop(); } } - logger.fine("JSyn synthesis thread exiting."); + LOGGER.debug("JSyn synthesis thread exiting."); } } @@ -406,7 +408,7 @@ public class SynthesisEngine implements Synthesizer { while (timeList != null) { while (!timeList.isEmpty()) { ScheduledCommand command = timeList.remove(0); - logger.fine("processing " + command + ", at time " + timeStamp.getTime()); + LOGGER.debug("processing " + command + ", at time " + timeStamp.getTime()); command.run(); } // Get next list of commands at the given time. @@ -419,7 +421,7 @@ public class SynthesisEngine implements Synthesizer { if ((Thread.currentThread() == engineThread) && (timeStamp.getTime() <= getCurrentTime())) { command.run(); } else { - logger.fine("scheduling " + command + ", at time " + timeStamp.getTime()); + LOGGER.debug("scheduling " + command + ", at time " + timeStamp.getTime()); commandQueue.add(timeStamp, command); } } @@ -539,7 +541,7 @@ public class SynthesisEngine implements Synthesizer { } private void internalStartUnit(UnitGenerator unit) { - // logger.info( "internalStartUnit " + unit + " with circuit " + + // LOGGER.info( "internalStartUnit " + unit + " with circuit " + // unit.getCircuit() ); if (unit.getCircuit() == null) { synchronized (runningUnitList) { @@ -550,7 +552,7 @@ public class SynthesisEngine implements Synthesizer { } // else // { - // logger.info( + // LOGGER.info( // "internalStartUnit detected race condition !!!! from old JSyn" + unit // + " with circuit " + unit.getCircuit() ); // } diff --git a/src/com/jsyn/exceptions/ChannelMismatchException.java b/src/main/java/com/jsyn/exceptions/ChannelMismatchException.java index a1554cd..a1554cd 100644 --- a/src/com/jsyn/exceptions/ChannelMismatchException.java +++ b/src/main/java/com/jsyn/exceptions/ChannelMismatchException.java diff --git a/src/com/jsyn/instruments/DrumWoodFM.java b/src/main/java/com/jsyn/instruments/DrumWoodFM.java index ba6cd1b..ba6cd1b 100644 --- a/src/com/jsyn/instruments/DrumWoodFM.java +++ b/src/main/java/com/jsyn/instruments/DrumWoodFM.java diff --git a/src/com/jsyn/instruments/DualOscillatorSynthVoice.java b/src/main/java/com/jsyn/instruments/DualOscillatorSynthVoice.java index c81041f..c81041f 100644 --- a/src/com/jsyn/instruments/DualOscillatorSynthVoice.java +++ b/src/main/java/com/jsyn/instruments/DualOscillatorSynthVoice.java diff --git a/src/com/jsyn/instruments/JSynInstrumentLibrary.java b/src/main/java/com/jsyn/instruments/JSynInstrumentLibrary.java index 9f111c3..9f111c3 100644 --- a/src/com/jsyn/instruments/JSynInstrumentLibrary.java +++ b/src/main/java/com/jsyn/instruments/JSynInstrumentLibrary.java diff --git a/src/com/jsyn/instruments/NoiseHit.java b/src/main/java/com/jsyn/instruments/NoiseHit.java index b8714fc..b8714fc 100644 --- a/src/com/jsyn/instruments/NoiseHit.java +++ b/src/main/java/com/jsyn/instruments/NoiseHit.java diff --git a/src/com/jsyn/instruments/SubtractiveSynthVoice.java b/src/main/java/com/jsyn/instruments/SubtractiveSynthVoice.java index 5cfc4b9..5cfc4b9 100644 --- a/src/com/jsyn/instruments/SubtractiveSynthVoice.java +++ b/src/main/java/com/jsyn/instruments/SubtractiveSynthVoice.java diff --git a/src/com/jsyn/instruments/WaveShapingVoice.java b/src/main/java/com/jsyn/instruments/WaveShapingVoice.java index 5044f21..5044f21 100644 --- a/src/com/jsyn/instruments/WaveShapingVoice.java +++ b/src/main/java/com/jsyn/instruments/WaveShapingVoice.java diff --git a/src/com/jsyn/io/AudioFifo.java b/src/main/java/com/jsyn/io/AudioFifo.java index 0c563e4..0c563e4 100644 --- a/src/com/jsyn/io/AudioFifo.java +++ b/src/main/java/com/jsyn/io/AudioFifo.java diff --git a/src/com/jsyn/io/AudioInputStream.java b/src/main/java/com/jsyn/io/AudioInputStream.java index f233ff1..f233ff1 100644 --- a/src/com/jsyn/io/AudioInputStream.java +++ b/src/main/java/com/jsyn/io/AudioInputStream.java diff --git a/src/com/jsyn/io/AudioOutputStream.java b/src/main/java/com/jsyn/io/AudioOutputStream.java index dada577..dada577 100644 --- a/src/com/jsyn/io/AudioOutputStream.java +++ b/src/main/java/com/jsyn/io/AudioOutputStream.java diff --git a/src/com/jsyn/midi/MessageParser.java b/src/main/java/com/jsyn/midi/MessageParser.java index d0f5d4d..d0f5d4d 100644 --- a/src/com/jsyn/midi/MessageParser.java +++ b/src/main/java/com/jsyn/midi/MessageParser.java diff --git a/src/com/jsyn/midi/MidiConstants.java b/src/main/java/com/jsyn/midi/MidiConstants.java index 8c92119..8c92119 100644 --- a/src/com/jsyn/midi/MidiConstants.java +++ b/src/main/java/com/jsyn/midi/MidiConstants.java diff --git a/src/com/jsyn/midi/MidiSynthesizer.java b/src/main/java/com/jsyn/midi/MidiSynthesizer.java index 30204b0..e5dbae7 100644 --- a/src/com/jsyn/midi/MidiSynthesizer.java +++ b/src/main/java/com/jsyn/midi/MidiSynthesizer.java @@ -16,8 +16,9 @@ package com.jsyn.midi; -import com.jsyn.instruments.DualOscillatorSynthVoice; import com.jsyn.util.MultiChannelSynthesizer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Map MIDI messages into calls to a MultiChannelSynthesizer. @@ -40,6 +41,8 @@ import com.jsyn.util.MultiChannelSynthesizer; */ public class MidiSynthesizer extends MessageParser { + private static final Logger LOGGER = LoggerFactory.getLogger(MidiSynthesizer.class); + private MultiChannelSynthesizer multiSynth; public MidiSynthesizer(MultiChannelSynthesizer multiSynth) { @@ -48,12 +51,12 @@ public class MidiSynthesizer extends MessageParser { @Override public void controlChange(int channel, int index, int value) { - //System.out.println("controlChange(" + channel + ", " + index + ", " + value + ")"); + //LOGGER.debug("controlChange(" + channel + ", " + index + ", " + value + ")"); double normalized = value * (1.0 / 127.0); switch (index) { case MidiConstants.CONTROLLER_MOD_WHEEL: double vibratoDepth = 0.1 * normalized; - System.out.println( "vibratoDepth = " + vibratoDepth ); + LOGGER.debug( "vibratoDepth = " + vibratoDepth ); multiSynth.setVibratoDepth(channel, vibratoDepth); break; case MidiConstants.CONTROLLER_TIMBRE: diff --git a/src/com/jsyn/package.html b/src/main/java/com/jsyn/package.html index cd73832..cd73832 100644 --- a/src/com/jsyn/package.html +++ b/src/main/java/com/jsyn/package.html diff --git a/src/com/jsyn/ports/ConnectableInput.java b/src/main/java/com/jsyn/ports/ConnectableInput.java index 3dae876..3dae876 100644 --- a/src/com/jsyn/ports/ConnectableInput.java +++ b/src/main/java/com/jsyn/ports/ConnectableInput.java diff --git a/src/com/jsyn/ports/ConnectableOutput.java b/src/main/java/com/jsyn/ports/ConnectableOutput.java index f42a799..f42a799 100644 --- a/src/com/jsyn/ports/ConnectableOutput.java +++ b/src/main/java/com/jsyn/ports/ConnectableOutput.java diff --git a/src/com/jsyn/ports/GettablePort.java b/src/main/java/com/jsyn/ports/GettablePort.java index aabf5ca..aabf5ca 100644 --- a/src/com/jsyn/ports/GettablePort.java +++ b/src/main/java/com/jsyn/ports/GettablePort.java diff --git a/src/com/jsyn/ports/InputMixingBlockPart.java b/src/main/java/com/jsyn/ports/InputMixingBlockPart.java index 5b54b99..2d28888 100644 --- a/src/com/jsyn/ports/InputMixingBlockPart.java +++ b/src/main/java/com/jsyn/ports/InputMixingBlockPart.java @@ -52,7 +52,7 @@ public class InputMixingBlockPart extends PortBlockPart { public double[] getValues() { double[] result; int numConnections = getConnectionCount(); - // System.out.println("numConnection = " + numConnections + " for " + + // LOGGER.debug("numConnection = " + numConnections + " for " + // this ); if (numConnections == 0) { // No connection so just use our own data. diff --git a/src/com/jsyn/ports/PortBlockPart.java b/src/main/java/com/jsyn/ports/PortBlockPart.java index ad75211..b1ced32 100644 --- a/src/com/jsyn/ports/PortBlockPart.java +++ b/src/main/java/com/jsyn/ports/PortBlockPart.java @@ -22,6 +22,8 @@ import com.jsyn.Synthesizer; import com.jsyn.engine.SynthesisEngine; import com.softsynth.shared.time.ScheduledCommand; import com.softsynth.shared.time.TimeStamp; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Part of a multi-part port, for example, the left side of a stereo port. @@ -29,6 +31,9 @@ import com.softsynth.shared.time.TimeStamp; * @author Phil Burk (C) 2009 Mobileer Inc */ public class PortBlockPart implements ConnectableOutput, ConnectableInput { + + private static final Logger LOGGER = LoggerFactory.getLogger(PortBlockPart.class); + private double[] values = new double[Synthesizer.FRAMES_PER_BLOCK]; private ArrayList<PortBlockPart> connections = new ArrayList<PortBlockPart>(); private UnitBlockPort unitBlockPort; @@ -61,10 +66,10 @@ public class PortBlockPart implements ConnectableOutput, ConnectableInput { } private void addConnection(PortBlockPart otherPart) { - // System.out.println("addConnection from " + this + " to " + otherPart + // LOGGER.debug("addConnection from " + this + " to " + otherPart // ); if (connections.contains(otherPart)) { - System.out.println("addConnection already had connection from " + this + " to " + LOGGER.debug("addConnection already had connection from " + this + " to " + otherPart); } else { connections.add(otherPart); @@ -72,7 +77,7 @@ public class PortBlockPart implements ConnectableOutput, ConnectableInput { } private void removeConnection(PortBlockPart otherPart) { - // System.out.println("removeConnection from " + this + " to " + + // LOGGER.debug("removeConnection from " + this + " to " + // otherPart ); connections.remove(otherPart); } diff --git a/src/com/jsyn/ports/QueueDataCommand.java b/src/main/java/com/jsyn/ports/QueueDataCommand.java index c23fbcd..0ef36e2 100644 --- a/src/com/jsyn/ports/QueueDataCommand.java +++ b/src/main/java/com/jsyn/ports/QueueDataCommand.java @@ -45,17 +45,17 @@ import com.softsynth.shared.time.ScheduledCommand; * { * public void started( QueueDataEvent event ) * { - * System.out.println("CALLBACK: Envelope started."); + * LOGGER.debug("CALLBACK: Envelope started."); * } * * public void looped( QueueDataEvent event ) * { - * System.out.println("CALLBACK: Envelope looped."); + * LOGGER.debug("CALLBACK: Envelope looped."); * } * * public void finished( QueueDataEvent event ) * { - * System.out.println("CALLBACK: Envelope finished."); + * LOGGER.debug("CALLBACK: Envelope finished."); * } * } * </code> diff --git a/src/com/jsyn/ports/QueueDataEvent.java b/src/main/java/com/jsyn/ports/QueueDataEvent.java index 2b93fab..2b93fab 100644 --- a/src/com/jsyn/ports/QueueDataEvent.java +++ b/src/main/java/com/jsyn/ports/QueueDataEvent.java diff --git a/src/com/jsyn/ports/SequentialDataCrossfade.java b/src/main/java/com/jsyn/ports/SequentialDataCrossfade.java index 25e1fd9..0c3d3b2 100644 --- a/src/com/jsyn/ports/SequentialDataCrossfade.java +++ b/src/main/java/com/jsyn/ports/SequentialDataCrossfade.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,25 +28,25 @@ import com.jsyn.data.SequentialDataCommon; * that you will hear a pop when this sample loops. To prevent the pop you could crossfade the * beginning of the loop with the region immediately after the end of the loop. To crossfade with * 5000 samples after the loop: - * + * * <pre> * SequentialDataCrossfade xfade = new SequentialDataCrossfade(sample, (50000 + 30000), 5000, sample, * 50000, 30000); * </pre> - * + * * After the crossfade you will hear the rest of the target at full volume. There are two regions * that determine what is returned from readDouble() * <ol> * <li>Crossfade region with size crossFadeFrames. It fades smoothly from source to target.</li> * <li>Steady region that is simply the target values with size (numFrames-crossFadeFrames).</li> * </ol> - * + * * <pre> * "Crossfade Region" "Steady Region" * |-- source fading out --| * |-- target fading in --|-- remainder of target at original volume --| * </pre> - * + * * @author Phil Burk */ class SequentialDataCrossfade extends SequentialDataCommon { @@ -74,10 +74,10 @@ class SequentialDataCrossfade extends SequentialDataCommon { assert ((sourceStartFrame + crossFadeFrames) <= source.getNumFrames()); assert ((targetStartFrame + numFrames) <= target.getNumFrames()); - // System.out.println( "WARNING! sourceStartFrame = " + sourceStartFrame + // LOGGER.debug( "WARNING! sourceStartFrame = " + sourceStartFrame // + ", crossFadeFrames = " + crossFadeFrames + ", maxFrame = " // + source.getNumFrames() + ", source = " + source ); - // System.out.println( " targetStartFrame = " + targetStartFrame + // LOGGER.debug( " targetStartFrame = " + targetStartFrame // + ", numFrames = " + numFrames + ", maxFrame = " // + target.getNumFrames() + ", target = " + target ); diff --git a/src/com/jsyn/ports/SettablePort.java b/src/main/java/com/jsyn/ports/SettablePort.java index e0db05c..e0db05c 100644 --- a/src/com/jsyn/ports/SettablePort.java +++ b/src/main/java/com/jsyn/ports/SettablePort.java diff --git a/src/com/jsyn/ports/UnitBlockPort.java b/src/main/java/com/jsyn/ports/UnitBlockPort.java index d7fc82f..d7fc82f 100644 --- a/src/com/jsyn/ports/UnitBlockPort.java +++ b/src/main/java/com/jsyn/ports/UnitBlockPort.java diff --git a/src/com/jsyn/ports/UnitDataQueueCallback.java b/src/main/java/com/jsyn/ports/UnitDataQueueCallback.java index dca4adc..dca4adc 100644 --- a/src/com/jsyn/ports/UnitDataQueueCallback.java +++ b/src/main/java/com/jsyn/ports/UnitDataQueueCallback.java diff --git a/src/com/jsyn/ports/UnitDataQueuePort.java b/src/main/java/com/jsyn/ports/UnitDataQueuePort.java index 5487589..13b2e2a 100644 --- a/src/com/jsyn/ports/UnitDataQueuePort.java +++ b/src/main/java/com/jsyn/ports/UnitDataQueuePort.java @@ -195,7 +195,7 @@ public class UnitDataQueuePort extends UnitPort { } finishingBlock = currentBlock; setCurrentBlock(null); - // System.out.println("advanceFrameIndex: currentBlock set null"); + // LOGGER.debug("advanceFrameIndex: currentBlock set null"); } } } @@ -400,7 +400,7 @@ public class UnitDataQueuePort extends UnitPort { if (queueableData.getReleaseBegin() < 0) { /* Sustain loop, no release loop. */ int susEnd = queueableData.getSustainEnd(); int size = queueableData.getNumFrames() - susEnd; - // System.out.println("queueOff: size = " + size ); + // LOGGER.debug("queueOff: size = " + size ); if (size <= 0) { // always queue something so that we can stop the loop // 20001117 diff --git a/src/com/jsyn/ports/UnitFunctionPort.java b/src/main/java/com/jsyn/ports/UnitFunctionPort.java index e45241a..e45241a 100644 --- a/src/com/jsyn/ports/UnitFunctionPort.java +++ b/src/main/java/com/jsyn/ports/UnitFunctionPort.java diff --git a/src/com/jsyn/ports/UnitGatePort.java b/src/main/java/com/jsyn/ports/UnitGatePort.java index 700aef8..700aef8 100644 --- a/src/com/jsyn/ports/UnitGatePort.java +++ b/src/main/java/com/jsyn/ports/UnitGatePort.java diff --git a/src/com/jsyn/ports/UnitInputPort.java b/src/main/java/com/jsyn/ports/UnitInputPort.java index 3eda1f6..3eda1f6 100644 --- a/src/com/jsyn/ports/UnitInputPort.java +++ b/src/main/java/com/jsyn/ports/UnitInputPort.java diff --git a/src/com/jsyn/ports/UnitOutputPort.java b/src/main/java/com/jsyn/ports/UnitOutputPort.java index 6fcd758..6fcd758 100644 --- a/src/com/jsyn/ports/UnitOutputPort.java +++ b/src/main/java/com/jsyn/ports/UnitOutputPort.java diff --git a/src/com/jsyn/ports/UnitPort.java b/src/main/java/com/jsyn/ports/UnitPort.java index a652e68..a652e68 100644 --- a/src/com/jsyn/ports/UnitPort.java +++ b/src/main/java/com/jsyn/ports/UnitPort.java diff --git a/src/com/jsyn/ports/UnitSpectralInputPort.java b/src/main/java/com/jsyn/ports/UnitSpectralInputPort.java index bdf0ff5..bdf0ff5 100644 --- a/src/com/jsyn/ports/UnitSpectralInputPort.java +++ b/src/main/java/com/jsyn/ports/UnitSpectralInputPort.java diff --git a/src/com/jsyn/ports/UnitSpectralOutputPort.java b/src/main/java/com/jsyn/ports/UnitSpectralOutputPort.java index 51633ce..51633ce 100644 --- a/src/com/jsyn/ports/UnitSpectralOutputPort.java +++ b/src/main/java/com/jsyn/ports/UnitSpectralOutputPort.java diff --git a/src/com/jsyn/ports/UnitVariablePort.java b/src/main/java/com/jsyn/ports/UnitVariablePort.java index 60b64fd..60b64fd 100644 --- a/src/com/jsyn/ports/UnitVariablePort.java +++ b/src/main/java/com/jsyn/ports/UnitVariablePort.java diff --git a/src/com/jsyn/ports/package.html b/src/main/java/com/jsyn/ports/package.html index 3547618..3547618 100644 --- a/src/com/jsyn/ports/package.html +++ b/src/main/java/com/jsyn/ports/package.html diff --git a/src/com/jsyn/scope/AudioScope.java b/src/main/java/com/jsyn/scope/AudioScope.java index 7b2a98c..7b2a98c 100644 --- a/src/com/jsyn/scope/AudioScope.java +++ b/src/main/java/com/jsyn/scope/AudioScope.java diff --git a/src/com/jsyn/scope/AudioScopeModel.java b/src/main/java/com/jsyn/scope/AudioScopeModel.java index 85c4413..85c4413 100644 --- a/src/com/jsyn/scope/AudioScopeModel.java +++ b/src/main/java/com/jsyn/scope/AudioScopeModel.java diff --git a/src/com/jsyn/scope/AudioScopeProbe.java b/src/main/java/com/jsyn/scope/AudioScopeProbe.java index f1aad65..f1aad65 100644 --- a/src/com/jsyn/scope/AudioScopeProbe.java +++ b/src/main/java/com/jsyn/scope/AudioScopeProbe.java diff --git a/src/com/jsyn/scope/DefaultWaveTraceModel.java b/src/main/java/com/jsyn/scope/DefaultWaveTraceModel.java index a123c0b..a123c0b 100644 --- a/src/com/jsyn/scope/DefaultWaveTraceModel.java +++ b/src/main/java/com/jsyn/scope/DefaultWaveTraceModel.java diff --git a/src/com/jsyn/scope/MultiChannelScopeProbeUnit.java b/src/main/java/com/jsyn/scope/MultiChannelScopeProbeUnit.java index 5be19f0..59bb635 100644 --- a/src/com/jsyn/scope/MultiChannelScopeProbeUnit.java +++ b/src/main/java/com/jsyn/scope/MultiChannelScopeProbeUnit.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,7 +23,7 @@ import com.softsynth.shared.time.ScheduledCommand; /** * Multi-channel scope probe with an independent trigger input. - * + * * @author Phil Burk (C) 2009 Mobileer Inc */ public class MultiChannelScopeProbeUnit extends UnitGenerator { @@ -53,7 +53,7 @@ public class MultiChannelScopeProbeUnit extends UnitGenerator { SignalBuffer displayBuffer; // Use double buffers. One for capture, one for display. - class SignalBuffer { + static class SignalBuffer { float[][] buffers; private int writeCursor; private int triggerIndex; diff --git a/src/com/jsyn/scope/TriggerModel.java b/src/main/java/com/jsyn/scope/TriggerModel.java index 0367d71..0367d71 100644 --- a/src/com/jsyn/scope/TriggerModel.java +++ b/src/main/java/com/jsyn/scope/TriggerModel.java diff --git a/src/com/jsyn/scope/WaveTraceModel.java b/src/main/java/com/jsyn/scope/WaveTraceModel.java index e9d8bf9..e9d8bf9 100644 --- a/src/com/jsyn/scope/WaveTraceModel.java +++ b/src/main/java/com/jsyn/scope/WaveTraceModel.java diff --git a/src/com/jsyn/scope/swing/AudioScopeProbeView.java b/src/main/java/com/jsyn/scope/swing/AudioScopeProbeView.java index 59526e1..59526e1 100644 --- a/src/com/jsyn/scope/swing/AudioScopeProbeView.java +++ b/src/main/java/com/jsyn/scope/swing/AudioScopeProbeView.java diff --git a/src/com/jsyn/scope/swing/AudioScopeView.java b/src/main/java/com/jsyn/scope/swing/AudioScopeView.java index ec1afa3..ec1afa3 100644 --- a/src/com/jsyn/scope/swing/AudioScopeView.java +++ b/src/main/java/com/jsyn/scope/swing/AudioScopeView.java diff --git a/src/com/jsyn/scope/swing/MultipleWaveDisplay.java b/src/main/java/com/jsyn/scope/swing/MultipleWaveDisplay.java index 0259850..0259850 100644 --- a/src/com/jsyn/scope/swing/MultipleWaveDisplay.java +++ b/src/main/java/com/jsyn/scope/swing/MultipleWaveDisplay.java diff --git a/src/com/jsyn/scope/swing/ScopeControlPanel.java b/src/main/java/com/jsyn/scope/swing/ScopeControlPanel.java index 7f3a026..7f3a026 100644 --- a/src/com/jsyn/scope/swing/ScopeControlPanel.java +++ b/src/main/java/com/jsyn/scope/swing/ScopeControlPanel.java diff --git a/src/com/jsyn/scope/swing/ScopeProbePanel.java b/src/main/java/com/jsyn/scope/swing/ScopeProbePanel.java index 9cb82af..a0dec91 100644 --- a/src/com/jsyn/scope/swing/ScopeProbePanel.java +++ b/src/main/java/com/jsyn/scope/swing/ScopeProbePanel.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,9 +29,14 @@ import javax.swing.JToggleButton.ToggleButtonModel; import com.jsyn.scope.AudioScopeProbe; import com.jsyn.swing.RotaryTextController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ScopeProbePanel extends JPanel { + + private static final Logger LOGGER = LoggerFactory.getLogger(ScopeProbePanel.class); private static final long serialVersionUID = 4511589171299298548L; + private AudioScopeProbeView audioScopeProbeView; private AudioScopeProbe audioScopeProbe; private RotaryTextController verticalScaleKnob; @@ -65,7 +70,7 @@ public class ScopeProbePanel extends JPanel { public void actionPerformed(ActionEvent e) { ToggleButtonModel model = (ToggleButtonModel) e.getSource(); boolean enabled = !model.isSelected(); - System.out.println("Knob enabled = " + enabled); + LOGGER.debug("Knob enabled = " + enabled); verticalScaleKnob.setEnabled(!model.isSelected()); } }); diff --git a/src/com/jsyn/scope/swing/ScopeTriggerPanel.java b/src/main/java/com/jsyn/scope/swing/ScopeTriggerPanel.java index 9c22aa1..9c22aa1 100644 --- a/src/com/jsyn/scope/swing/ScopeTriggerPanel.java +++ b/src/main/java/com/jsyn/scope/swing/ScopeTriggerPanel.java diff --git a/src/com/jsyn/scope/swing/WaveTraceView.java b/src/main/java/com/jsyn/scope/swing/WaveTraceView.java index 849a6f4..849a6f4 100644 --- a/src/com/jsyn/scope/swing/WaveTraceView.java +++ b/src/main/java/com/jsyn/scope/swing/WaveTraceView.java diff --git a/src/com/jsyn/swing/ASCIIMusicKeyboard.java b/src/main/java/com/jsyn/swing/ASCIIMusicKeyboard.java index f1379d8..dc02259 100644 --- a/src/com/jsyn/swing/ASCIIMusicKeyboard.java +++ b/src/main/java/com/jsyn/swing/ASCIIMusicKeyboard.java @@ -16,6 +16,9 @@ package com.jsyn.swing; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -35,6 +38,9 @@ import javax.swing.JPanel; */ @SuppressWarnings("serial") public abstract class ASCIIMusicKeyboard extends JPanel { + + private static final Logger LOGGER = LoggerFactory.getLogger(ASCIIMusicKeyboard.class); + private final JCheckBox sustainBox; private final JButton focusButton; public static final String PENTATONIC_KEYS = "zxcvbasdfgqwert12345"; @@ -63,7 +69,7 @@ public abstract class ASCIIMusicKeyboard extends JPanel { public void keyPressed(KeyEvent e) { int key = e.getKeyChar(); int idx = keyboardLayout.indexOf(key); - System.out.println("keyPressed " + idx); + LOGGER.debug("keyPressed " + idx); if (idx >= 0) { if (!pressedKeys.contains(idx)) { keyOn(convertIndexToPitch(idx)); @@ -80,7 +86,7 @@ public abstract class ASCIIMusicKeyboard extends JPanel { public void keyReleased(KeyEvent e) { int key = e.getKeyChar(); int idx = keyboardLayout.indexOf(key); - System.out.println("keyReleased " + idx); + LOGGER.debug("keyReleased " + idx); if (idx >= 0) { if (!sustainBox.isSelected()) { noteOffInternal(idx); diff --git a/src/com/jsyn/swing/DoubleBoundedRangeModel.java b/src/main/java/com/jsyn/swing/DoubleBoundedRangeModel.java index 647e8da..647e8da 100644 --- a/src/com/jsyn/swing/DoubleBoundedRangeModel.java +++ b/src/main/java/com/jsyn/swing/DoubleBoundedRangeModel.java diff --git a/src/com/jsyn/swing/DoubleBoundedRangeSlider.java b/src/main/java/com/jsyn/swing/DoubleBoundedRangeSlider.java index 3642221..81b67df 100644 --- a/src/com/jsyn/swing/DoubleBoundedRangeSlider.java +++ b/src/main/java/com/jsyn/swing/DoubleBoundedRangeSlider.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,13 +29,13 @@ import com.jsyn.util.NumericOutput; /** * Slider that takes a DoubleBoundedRangeModel. It displays the current value in a titled border. - * + * * @author Phil Burk, (C) 2002 SoftSynth.com, PROPRIETARY and CONFIDENTIAL */ public class DoubleBoundedRangeSlider extends JSlider { - /**
- *
+ /** + * */ private static final long serialVersionUID = -440390322602838998L; /** Places after decimal point for display. */ @@ -91,7 +91,7 @@ public class DoubleBoundedRangeSlider extends JSlider { while (dval <= model.getDoubleMaximum()) { int sliderValue = model.doubleToSlider(dval); String text = NumericOutput.doubleToString(dval, 0, places); - labelTable.put(new Integer(sliderValue), new JLabel(text)); + labelTable.put(sliderValue, new JLabel(text)); dval = nextLabelValue(dval, delta); } setLabelTable(labelTable); diff --git a/src/com/jsyn/swing/DoubleBoundedTextField.java b/src/main/java/com/jsyn/swing/DoubleBoundedTextField.java index 3301bb1..3301bb1 100644 --- a/src/com/jsyn/swing/DoubleBoundedTextField.java +++ b/src/main/java/com/jsyn/swing/DoubleBoundedTextField.java diff --git a/src/com/jsyn/swing/EnvelopeEditorBox.java b/src/main/java/com/jsyn/swing/EnvelopeEditorBox.java index aab5762..2db4c29 100644 --- a/src/com/jsyn/swing/EnvelopeEditorBox.java +++ b/src/main/java/com/jsyn/swing/EnvelopeEditorBox.java @@ -100,7 +100,7 @@ public class EnvelopeEditorBox extends XYController implements MouseListener, Mo points.setReleaseLoop(start, end); break; } - // System.out.println("start = " + start + ", end = " + end ); + // LOGGER.debug("start = " + start + ", end = " + end ); } /** Set mode to either EDIT_POINTS or SELECT_SUSTAIN, SELECT_RELEASE; */ @@ -173,10 +173,10 @@ public class EnvelopeEditorBox extends XYController implements MouseListener, Mo double px = 0.0; double wxLow = wx - wxAperture; double wxHigh = wx + wxAperture; - // System.out.println("wxLow = " + wxLow + ", wxHigh = " + wxHigh ); + // LOGGER.debug("wxLow = " + wxLow + ", wxHigh = " + wxHigh ); double wyLow = wy - wyAperture; double wyHigh = wy + wyAperture; - // System.out.println("wyLow = " + wyLow + ", wyHigh = " + wyHigh ); + // LOGGER.debug("wyLow = " + wyLow + ", wyHigh = " + wyHigh ); double wxScale = 1.0 / wxAperture; // only divide once, then multiply double wyScale = 1.0 / wyAperture; int bestPoint = -1; @@ -185,13 +185,13 @@ public class EnvelopeEditorBox extends XYController implements MouseListener, Mo double dar[] = points.getPoint(i); px += dar[0]; double py = dar[1]; - // System.out.println("px = " + px + ", py = " + py ); + // LOGGER.debug("px = " + px + ", py = " + py ); if ((px > wxLow) && (px < wxHigh) && (py > wyLow) && (py < wyHigh)) { /* Inside pick range. Calculate distance squared. */ double ndx = (px - wx) * wxScale; double ndy = (py - wy) * wyScale; double dist = (ndx * ndx) + (ndy * ndy); - // System.out.println("dist = " + dist ); + // LOGGER.debug("dist = " + dist ); if (dist < bestDistance) { bestPoint = i; bestDistance = dist; @@ -220,7 +220,7 @@ public class EnvelopeEditorBox extends XYController implements MouseListener, Mo rangeEnd = rangeStart; rangeStart = temp; } - // System.out.println("clickUpRange: gx = " + gx + ", rangeStart = " + + // LOGGER.debug("clickUpRange: gx = " + gx + ", rangeStart = " + // rangeStart ); double wx = convertGXtoWX(rangeStart); int i0 = findPointBefore(wx); @@ -250,11 +250,11 @@ public class EnvelopeEditorBox extends XYController implements MouseListener, Mo double wy = convertGYtoWY(gy); // calculate world values for aperture double wxAp = convertGXtoWX(radius + 2) - convertGXtoWX(0); - // System.out.println("wxAp = " + wxAp ); + // LOGGER.debug("wxAp = " + wxAp ); double wyAp = convertGYtoWY(0) - convertGYtoWY(radius + 2); - // System.out.println("wyAp = " + wyAp ); + // LOGGER.debug("wyAp = " + wyAp ); int pnt = pickPoint(wx, wxAp, wy, wyAp); - // System.out.println("pickPoint = " + pnt); + // LOGGER.debug("pickPoint = " + pnt); if (shiftDown) { if (pnt >= 0) { points.removePoint(pnt); @@ -266,7 +266,7 @@ public class EnvelopeEditorBox extends XYController implements MouseListener, Mo if (points.size() < maxPoints) // add if room { pnt = findPointBefore(wx); - // System.out.println("pointBefore = " + pnt); + // LOGGER.debug("pointBefore = " + pnt); dragIndex = pnt + 1; if (pnt == (points.size() - 1)) { points.add(wx - xBefore, wy); @@ -286,7 +286,7 @@ public class EnvelopeEditorBox extends XYController implements MouseListener, Mo else dragLowLimit = xPicked - points.getPoint(dragIndex)[0]; dragHighLimit = xPicked + (maximumXRange - points.getTotalDuration()); - // System.out.println("dragLowLimit = " + dragLowLimit ); + // LOGGER.debug("dragLowLimit = " + dragLowLimit ); } } // Set up drag point if we are dragging. @@ -549,13 +549,13 @@ public class EnvelopeEditorBox extends XYController implements MouseListener, Mo // endless jitter, FIXME - still // needed after repaint() // removed from setMaxWorldX? - // System.out.println("newMax = " + newMax ); + // LOGGER.debug("newMax = " + newMax ); if (newMax < minimumXRange) newMax = minimumXRange; setMaxWorldX(newMax); } } - // System.out.println("total X = " + wx ); + // LOGGER.debug("total X = " + wx ); drawUnderlay(g); diff --git a/src/com/jsyn/swing/EnvelopeEditorPanel.java b/src/main/java/com/jsyn/swing/EnvelopeEditorPanel.java index dc9f2cd..dc9f2cd 100644 --- a/src/com/jsyn/swing/EnvelopeEditorPanel.java +++ b/src/main/java/com/jsyn/swing/EnvelopeEditorPanel.java diff --git a/src/com/jsyn/swing/EnvelopePoints.java b/src/main/java/com/jsyn/swing/EnvelopePoints.java index ab4ed03..ab4ed03 100644 --- a/src/com/jsyn/swing/EnvelopePoints.java +++ b/src/main/java/com/jsyn/swing/EnvelopePoints.java diff --git a/src/com/jsyn/swing/ExponentialRangeModel.java b/src/main/java/com/jsyn/swing/ExponentialRangeModel.java index 4411947..c807000 100644 --- a/src/com/jsyn/swing/ExponentialRangeModel.java +++ b/src/main/java/com/jsyn/swing/ExponentialRangeModel.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,27 +16,33 @@ package com.jsyn.swing; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Maps integer range info to a double value along an exponential scale. - * + * * <pre> - * - * x = ival / resolution
- * f(x) = a*(rootˆcx) + b
- * f(0.0) = dmin
- * f(1.0) = dmax
- * b = dmin - a
- * a = (dmax - dmin) / (rootˆc - 1)
- *
- * Inverse function:
+ * + * x = ival / resolution + * f(x) = a*(rootˆcx) + b + * f(0.0) = dmin + * f(1.0) = dmax + * b = dmin - a + * a = (dmax - dmin) / (rootˆc - 1) + * + * Inverse function: * x = log( (y-b)/a ) / log(root) - * + * * </pre> - * + * * @author Phil Burk, (C) 2011 Mobileer Inc */ public class ExponentialRangeModel extends DoubleBoundedRangeModel { + + private static final Logger LOGGER = LoggerFactory.getLogger(ExponentialRangeModel.class); private static final long serialVersionUID = -142785624892302160L; + double a = 1.0; double b = -1.0; double span = 1.0; @@ -84,8 +90,7 @@ public class ExponentialRangeModel extends DoubleBoundedRangeModel { public double sliderToDouble(int sliderValue) { updateCoefficients(); // TODO optimize when we call this double x = (double) sliderValue / getMaximum(); - double y = (a * Math.pow(root, span * x)) + b; - return y; + return (a * Math.pow(root, span * x)) + b; } @Override @@ -99,7 +104,7 @@ public class ExponentialRangeModel extends DoubleBoundedRangeModel { public void test(int sliderValue) { double dval = sliderToDouble(sliderValue); int ival = doubleToSlider(dval); - System.out.println(sliderValue + " => " + dval + " => " + ival); + LOGGER.debug(sliderValue + " => " + dval + " => " + ival); } } diff --git a/src/com/jsyn/swing/InstrumentBrowser.java b/src/main/java/com/jsyn/swing/InstrumentBrowser.java index 55575a3..8e74660 100644 --- a/src/com/jsyn/swing/InstrumentBrowser.java +++ b/src/main/java/com/jsyn/swing/InstrumentBrowser.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,7 @@ import com.jsyn.util.VoiceDescription; /** * Display a list of VoiceDescriptions and their associated presets. Notify PresetSelectionListeners * when a preset is selected. - * + * * @author Phil Burk (C) 2012 Mobileer Inc */ @SuppressWarnings("serial") @@ -41,7 +41,7 @@ public class InstrumentBrowser extends JPanel { private InstrumentLibrary library; private JScrollPane listScroller2; private VoiceDescription voiceDescription; - private ArrayList<PresetSelectionListener> listeners = new ArrayList<PresetSelectionListener>(); + private ArrayList<PresetSelectionListener> listeners = new ArrayList<>(); public InstrumentBrowser(InstrumentLibrary library) { this.library = library; @@ -53,7 +53,7 @@ public class InstrumentBrowser extends JPanel { instrumentList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { - if (e.getValueIsAdjusting() == false) { + if (!e.getValueIsAdjusting()) { int n = instrumentList.getSelectedIndex(); if (n >= 0) { showPresetList(n); diff --git a/src/com/jsyn/swing/JAppletFrame.java b/src/main/java/com/jsyn/swing/JAppletFrame.java index 53bd65b..53bd65b 100644 --- a/src/com/jsyn/swing/JAppletFrame.java +++ b/src/main/java/com/jsyn/swing/JAppletFrame.java diff --git a/src/com/jsyn/swing/PortBoundedRangeModel.java b/src/main/java/com/jsyn/swing/PortBoundedRangeModel.java index a5cf841..a5cf841 100644 --- a/src/com/jsyn/swing/PortBoundedRangeModel.java +++ b/src/main/java/com/jsyn/swing/PortBoundedRangeModel.java diff --git a/src/com/jsyn/swing/PortControllerFactory.java b/src/main/java/com/jsyn/swing/PortControllerFactory.java index a73d047..a73d047 100644 --- a/src/com/jsyn/swing/PortControllerFactory.java +++ b/src/main/java/com/jsyn/swing/PortControllerFactory.java diff --git a/src/com/jsyn/swing/PortModelFactory.java b/src/main/java/com/jsyn/swing/PortModelFactory.java index 8bec76a..8bec76a 100644 --- a/src/com/jsyn/swing/PortModelFactory.java +++ b/src/main/java/com/jsyn/swing/PortModelFactory.java diff --git a/src/com/jsyn/swing/PresetSelectionListener.java b/src/main/java/com/jsyn/swing/PresetSelectionListener.java index daf0310..daf0310 100644 --- a/src/com/jsyn/swing/PresetSelectionListener.java +++ b/src/main/java/com/jsyn/swing/PresetSelectionListener.java diff --git a/src/com/jsyn/swing/RotaryController.java b/src/main/java/com/jsyn/swing/RotaryController.java index c26c37f..c26c37f 100644 --- a/src/com/jsyn/swing/RotaryController.java +++ b/src/main/java/com/jsyn/swing/RotaryController.java diff --git a/src/com/jsyn/swing/RotaryTextController.java b/src/main/java/com/jsyn/swing/RotaryTextController.java index 81d6614..81d6614 100644 --- a/src/com/jsyn/swing/RotaryTextController.java +++ b/src/main/java/com/jsyn/swing/RotaryTextController.java diff --git a/src/com/jsyn/swing/SoundTweaker.java b/src/main/java/com/jsyn/swing/SoundTweaker.java index 043677e..dc48c8f 100644 --- a/src/com/jsyn/swing/SoundTweaker.java +++ b/src/main/java/com/jsyn/swing/SoundTweaker.java @@ -87,7 +87,7 @@ public class SoundTweaker extends JPanel { @SuppressWarnings("serial") private ASCIIMusicKeyboard createPolyphonicKeyboard() { - ASCIIMusicKeyboard keyboard = new ASCIIMusicKeyboard() { + return new ASCIIMusicKeyboard() { @Override public void keyOff(int pitch) { ((Instrument) source).noteOff(pitch, synth.createTimeStamp()); @@ -99,12 +99,11 @@ public class SoundTweaker extends JPanel { ((Instrument) source).noteOn(pitch, freq, 0.5, synth.createTimeStamp()); } }; - return keyboard; } @SuppressWarnings("serial") private ASCIIMusicKeyboard createMonophonicKeyboard() { - ASCIIMusicKeyboard keyboard = new ASCIIMusicKeyboard() { + return new ASCIIMusicKeyboard() { @Override public void keyOff(int pitch) { ((UnitVoice) source).noteOff(synth.createTimeStamp()); @@ -116,7 +115,6 @@ public class SoundTweaker extends JPanel { ((UnitVoice) source).noteOn(freq, 0.5, synth.createTimeStamp()); } }; - return keyboard; } } diff --git a/src/com/jsyn/swing/XYController.java b/src/main/java/com/jsyn/swing/XYController.java index 0d97c62..0d97c62 100644 --- a/src/com/jsyn/swing/XYController.java +++ b/src/main/java/com/jsyn/swing/XYController.java diff --git a/src/com/jsyn/unitgen/Add.java b/src/main/java/com/jsyn/unitgen/Add.java index 5a2a24c..c91fc85 100644 --- a/src/com/jsyn/unitgen/Add.java +++ b/src/main/java/com/jsyn/unitgen/Add.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,15 +18,15 @@ package com.jsyn.unitgen; /** * This unit performs a signed addition on its two inputs. <br> - * + * * <pre> * output = inputA + inputB * </pre> - * + * * <br> * Note that signals connected to an InputPort are automatically added together so you may not need * this unit. - * + * * @author Phil Burk (C) 2009 Mobileer Inc * @version 016 * @see MultiplyAdd @@ -40,11 +40,11 @@ public class Add extends UnitBinaryOperator { double[] bValues = inputB.getValues(); double[] outputs = output.getValues(); - // System.out.println("adder = " + this); - // System.out.println("A = " + aValues[0]); + // LOGGER.debug("adder = " + this); + // LOGGER.debug("A = " + aValues[0]); for (int i = start; i < limit; i++) { outputs[i] = aValues[i] + bValues[i]; } - // System.out.println("add out = " + outputs[0]); + // LOGGER.debug("add out = " + outputs[0]); } } diff --git a/src/com/jsyn/unitgen/AsymptoticRamp.java b/src/main/java/com/jsyn/unitgen/AsymptoticRamp.java index 8b51294..8b51294 100644 --- a/src/com/jsyn/unitgen/AsymptoticRamp.java +++ b/src/main/java/com/jsyn/unitgen/AsymptoticRamp.java diff --git a/src/com/jsyn/unitgen/BrownNoise.java b/src/main/java/com/jsyn/unitgen/BrownNoise.java index e70b7f4..e70b7f4 100644 --- a/src/com/jsyn/unitgen/BrownNoise.java +++ b/src/main/java/com/jsyn/unitgen/BrownNoise.java diff --git a/src/com/jsyn/unitgen/ChannelIn.java b/src/main/java/com/jsyn/unitgen/ChannelIn.java index c440b4f..c440b4f 100644 --- a/src/com/jsyn/unitgen/ChannelIn.java +++ b/src/main/java/com/jsyn/unitgen/ChannelIn.java diff --git a/src/com/jsyn/unitgen/ChannelOut.java b/src/main/java/com/jsyn/unitgen/ChannelOut.java index 8ef0677..8ef0677 100644 --- a/src/com/jsyn/unitgen/ChannelOut.java +++ b/src/main/java/com/jsyn/unitgen/ChannelOut.java diff --git a/src/com/jsyn/unitgen/Circuit.java b/src/main/java/com/jsyn/unitgen/Circuit.java index 01cb860..01cb860 100644 --- a/src/com/jsyn/unitgen/Circuit.java +++ b/src/main/java/com/jsyn/unitgen/Circuit.java diff --git a/src/com/jsyn/unitgen/Compare.java b/src/main/java/com/jsyn/unitgen/Compare.java index 7de2e53..7de2e53 100644 --- a/src/com/jsyn/unitgen/Compare.java +++ b/src/main/java/com/jsyn/unitgen/Compare.java diff --git a/src/com/jsyn/unitgen/ContinuousRamp.java b/src/main/java/com/jsyn/unitgen/ContinuousRamp.java index dd90445..dd90445 100644 --- a/src/com/jsyn/unitgen/ContinuousRamp.java +++ b/src/main/java/com/jsyn/unitgen/ContinuousRamp.java diff --git a/src/com/jsyn/unitgen/CrossFade.java b/src/main/java/com/jsyn/unitgen/CrossFade.java index 4375fa6..4375fa6 100644 --- a/src/com/jsyn/unitgen/CrossFade.java +++ b/src/main/java/com/jsyn/unitgen/CrossFade.java diff --git a/src/com/jsyn/unitgen/Delay.java b/src/main/java/com/jsyn/unitgen/Delay.java index aa450a9..aa450a9 100644 --- a/src/com/jsyn/unitgen/Delay.java +++ b/src/main/java/com/jsyn/unitgen/Delay.java diff --git a/src/com/jsyn/unitgen/Divide.java b/src/main/java/com/jsyn/unitgen/Divide.java index cddcd7c..cddcd7c 100644 --- a/src/com/jsyn/unitgen/Divide.java +++ b/src/main/java/com/jsyn/unitgen/Divide.java diff --git a/src/com/jsyn/unitgen/DualInTwoOut.java b/src/main/java/com/jsyn/unitgen/DualInTwoOut.java index ec7dff5..ec7dff5 100644 --- a/src/com/jsyn/unitgen/DualInTwoOut.java +++ b/src/main/java/com/jsyn/unitgen/DualInTwoOut.java diff --git a/src/com/jsyn/unitgen/EdgeDetector.java b/src/main/java/com/jsyn/unitgen/EdgeDetector.java index e314f7d..e314f7d 100644 --- a/src/com/jsyn/unitgen/EdgeDetector.java +++ b/src/main/java/com/jsyn/unitgen/EdgeDetector.java diff --git a/src/com/jsyn/unitgen/EnvelopeAttackDecay.java b/src/main/java/com/jsyn/unitgen/EnvelopeAttackDecay.java index db3ecaa..db3ecaa 100644 --- a/src/com/jsyn/unitgen/EnvelopeAttackDecay.java +++ b/src/main/java/com/jsyn/unitgen/EnvelopeAttackDecay.java diff --git a/src/com/jsyn/unitgen/EnvelopeDAHDSR.java b/src/main/java/com/jsyn/unitgen/EnvelopeDAHDSR.java index c5ebe83..c5ebe83 100644 --- a/src/com/jsyn/unitgen/EnvelopeDAHDSR.java +++ b/src/main/java/com/jsyn/unitgen/EnvelopeDAHDSR.java diff --git a/src/com/jsyn/unitgen/ExponentialRamp.java b/src/main/java/com/jsyn/unitgen/ExponentialRamp.java index 36159b4..36159b4 100644 --- a/src/com/jsyn/unitgen/ExponentialRamp.java +++ b/src/main/java/com/jsyn/unitgen/ExponentialRamp.java diff --git a/src/com/jsyn/unitgen/FFT.java b/src/main/java/com/jsyn/unitgen/FFT.java index 63fce50..63fce50 100644 --- a/src/com/jsyn/unitgen/FFT.java +++ b/src/main/java/com/jsyn/unitgen/FFT.java diff --git a/src/com/jsyn/unitgen/FFTBase.java b/src/main/java/com/jsyn/unitgen/FFTBase.java index 055c04b..055c04b 100644 --- a/src/com/jsyn/unitgen/FFTBase.java +++ b/src/main/java/com/jsyn/unitgen/FFTBase.java diff --git a/src/com/jsyn/unitgen/FilterAllPass.java b/src/main/java/com/jsyn/unitgen/FilterAllPass.java index 749b2d6..749b2d6 100644 --- a/src/com/jsyn/unitgen/FilterAllPass.java +++ b/src/main/java/com/jsyn/unitgen/FilterAllPass.java diff --git a/src/com/jsyn/unitgen/FilterBandPass.java b/src/main/java/com/jsyn/unitgen/FilterBandPass.java index b103400..b103400 100644 --- a/src/com/jsyn/unitgen/FilterBandPass.java +++ b/src/main/java/com/jsyn/unitgen/FilterBandPass.java diff --git a/src/com/jsyn/unitgen/FilterBandStop.java b/src/main/java/com/jsyn/unitgen/FilterBandStop.java index d4f5249..d4f5249 100644 --- a/src/com/jsyn/unitgen/FilterBandStop.java +++ b/src/main/java/com/jsyn/unitgen/FilterBandStop.java diff --git a/src/com/jsyn/unitgen/FilterBiquad.java b/src/main/java/com/jsyn/unitgen/FilterBiquad.java index f9b792f..f9b792f 100644 --- a/src/com/jsyn/unitgen/FilterBiquad.java +++ b/src/main/java/com/jsyn/unitgen/FilterBiquad.java diff --git a/src/com/jsyn/unitgen/FilterBiquadCommon.java b/src/main/java/com/jsyn/unitgen/FilterBiquadCommon.java index f21c8e7..d84b39a 100644 --- a/src/com/jsyn/unitgen/FilterBiquadCommon.java +++ b/src/main/java/com/jsyn/unitgen/FilterBiquadCommon.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +20,7 @@ import com.jsyn.ports.UnitInputPort; /** * Extend this class to create a filter that implements a Biquad filter with a Q port. - * + * * @author Phil Burk (C) 2009 Mobileer Inc Translated from 'C' to Java by Lisa * Tolentino. */ @@ -55,7 +55,7 @@ public abstract class FilterBiquadCommon extends FilterBiquad { cos_omega = Math.cos(omega); // compute cosine sin_omega = Math.sin(omega); // compute sine alpha = sin_omega / (2.0 * Q); // set alpha - // System.out.println("Q = " + Q + ", omega = " + omega + + // LOGGER.debug("Q = " + Q + ", omega = " + omega + // ", cos(omega) = " + cos_omega + ", alpha = " + alpha ); } diff --git a/src/com/jsyn/unitgen/FilterBiquadShelf.java b/src/main/java/com/jsyn/unitgen/FilterBiquadShelf.java index 737d18d..737d18d 100644 --- a/src/com/jsyn/unitgen/FilterBiquadShelf.java +++ b/src/main/java/com/jsyn/unitgen/FilterBiquadShelf.java diff --git a/src/com/jsyn/unitgen/FilterFourPoles.java b/src/main/java/com/jsyn/unitgen/FilterFourPoles.java index 39a47c7..39a47c7 100644 --- a/src/com/jsyn/unitgen/FilterFourPoles.java +++ b/src/main/java/com/jsyn/unitgen/FilterFourPoles.java diff --git a/src/com/jsyn/unitgen/FilterHighPass.java b/src/main/java/com/jsyn/unitgen/FilterHighPass.java index 76ad6b9..76ad6b9 100644 --- a/src/com/jsyn/unitgen/FilterHighPass.java +++ b/src/main/java/com/jsyn/unitgen/FilterHighPass.java diff --git a/src/com/jsyn/unitgen/FilterHighShelf.java b/src/main/java/com/jsyn/unitgen/FilterHighShelf.java index 449090a..449090a 100644 --- a/src/com/jsyn/unitgen/FilterHighShelf.java +++ b/src/main/java/com/jsyn/unitgen/FilterHighShelf.java diff --git a/src/com/jsyn/unitgen/FilterLowPass.java b/src/main/java/com/jsyn/unitgen/FilterLowPass.java index 1557367..1557367 100644 --- a/src/com/jsyn/unitgen/FilterLowPass.java +++ b/src/main/java/com/jsyn/unitgen/FilterLowPass.java diff --git a/src/com/jsyn/unitgen/FilterLowShelf.java b/src/main/java/com/jsyn/unitgen/FilterLowShelf.java index cf41f45..cf41f45 100644 --- a/src/com/jsyn/unitgen/FilterLowShelf.java +++ b/src/main/java/com/jsyn/unitgen/FilterLowShelf.java diff --git a/src/com/jsyn/unitgen/FilterOnePole.java b/src/main/java/com/jsyn/unitgen/FilterOnePole.java index 090e42b..090e42b 100644 --- a/src/com/jsyn/unitgen/FilterOnePole.java +++ b/src/main/java/com/jsyn/unitgen/FilterOnePole.java diff --git a/src/com/jsyn/unitgen/FilterOnePoleOneZero.java b/src/main/java/com/jsyn/unitgen/FilterOnePoleOneZero.java index ed1868c..ed1868c 100644 --- a/src/com/jsyn/unitgen/FilterOnePoleOneZero.java +++ b/src/main/java/com/jsyn/unitgen/FilterOnePoleOneZero.java diff --git a/src/com/jsyn/unitgen/FilterOneZero.java b/src/main/java/com/jsyn/unitgen/FilterOneZero.java index 2a07a16..2a07a16 100644 --- a/src/com/jsyn/unitgen/FilterOneZero.java +++ b/src/main/java/com/jsyn/unitgen/FilterOneZero.java diff --git a/src/com/jsyn/unitgen/FilterPeakingEQ.java b/src/main/java/com/jsyn/unitgen/FilterPeakingEQ.java index bec7096..bec7096 100644 --- a/src/com/jsyn/unitgen/FilterPeakingEQ.java +++ b/src/main/java/com/jsyn/unitgen/FilterPeakingEQ.java diff --git a/src/com/jsyn/unitgen/FilterStateVariable.java b/src/main/java/com/jsyn/unitgen/FilterStateVariable.java index 74dde5e..3a0f05c 100644 --- a/src/com/jsyn/unitgen/FilterStateVariable.java +++ b/src/main/java/com/jsyn/unitgen/FilterStateVariable.java @@ -106,13 +106,13 @@ public class FilterStateVariable extends TunableFilter { outputs[i] = lowPassValue * (amplitudes[i]); double highPassValue = inputs[i] - (reses[i] * bandPassValue) - lowPassValue; - // System.out.println("low = " + lowPassValue + ", band = " + bandPassValue + + // LOGGER.debug("low = " + lowPassValue + ", band = " + bandPassValue + // ", high = " + highPassValue ); highs[i] = highPassValue; bandPassValue = (freqInternal * highPassValue) + bandPassValue; bands[i] = bandPassValue; - // System.out.println("low = " + lowPassValue + ", band = " + bandPassValue + + // LOGGER.debug("low = " + lowPassValue + ", band = " + bandPassValue + // ", high = " + highPassValue ); } } diff --git a/src/com/jsyn/unitgen/FilterTwoPoles.java b/src/main/java/com/jsyn/unitgen/FilterTwoPoles.java index 0c68a64..0c68a64 100644 --- a/src/com/jsyn/unitgen/FilterTwoPoles.java +++ b/src/main/java/com/jsyn/unitgen/FilterTwoPoles.java diff --git a/src/com/jsyn/unitgen/FilterTwoPolesTwoZeros.java b/src/main/java/com/jsyn/unitgen/FilterTwoPolesTwoZeros.java index cde279f..cde279f 100644 --- a/src/com/jsyn/unitgen/FilterTwoPolesTwoZeros.java +++ b/src/main/java/com/jsyn/unitgen/FilterTwoPolesTwoZeros.java diff --git a/src/com/jsyn/unitgen/FixedRateMonoReader.java b/src/main/java/com/jsyn/unitgen/FixedRateMonoReader.java index c6edc23..c6edc23 100644 --- a/src/com/jsyn/unitgen/FixedRateMonoReader.java +++ b/src/main/java/com/jsyn/unitgen/FixedRateMonoReader.java diff --git a/src/com/jsyn/unitgen/FixedRateMonoWriter.java b/src/main/java/com/jsyn/unitgen/FixedRateMonoWriter.java index c215c55..c215c55 100644 --- a/src/com/jsyn/unitgen/FixedRateMonoWriter.java +++ b/src/main/java/com/jsyn/unitgen/FixedRateMonoWriter.java diff --git a/src/com/jsyn/unitgen/FixedRateStereoReader.java b/src/main/java/com/jsyn/unitgen/FixedRateStereoReader.java index c5c00ce..6dcf72c 100644 --- a/src/com/jsyn/unitgen/FixedRateStereoReader.java +++ b/src/main/java/com/jsyn/unitgen/FixedRateStereoReader.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +20,7 @@ import com.jsyn.ports.UnitOutputPort; /** * Simple stereo sample player. Play one sample per audio frame with no interpolation. - * + * * @author Phil Burk (C) 2009 Mobileer Inc */ public class FixedRateStereoReader extends SequentialDataReader { @@ -39,11 +39,11 @@ public class FixedRateStereoReader extends SequentialDataReader { if (dataQueue.hasMore()) { dataQueue.beginFrame(getFramePeriod()); double fdata = dataQueue.readCurrentChannelDouble(0); - // System.out.println("SampleReader_16F2: left = " + fdata ); + // LOGGER.debug("SampleReader_16F2: left = " + fdata ); double amp = amplitudes[i]; output0s[i] = fdata * amp; fdata = dataQueue.readCurrentChannelDouble(1); - // System.out.println("SampleReader_16F2: right = " + fdata ); + // LOGGER.debug("SampleReader_16F2: right = " + fdata ); output1s[i] = fdata * amp; dataQueue.endFrame(); } else { diff --git a/src/com/jsyn/unitgen/FixedRateStereoWriter.java b/src/main/java/com/jsyn/unitgen/FixedRateStereoWriter.java index e4502f9..e4502f9 100644 --- a/src/com/jsyn/unitgen/FixedRateStereoWriter.java +++ b/src/main/java/com/jsyn/unitgen/FixedRateStereoWriter.java diff --git a/src/com/jsyn/unitgen/FourWayFade.java b/src/main/java/com/jsyn/unitgen/FourWayFade.java index c7fd22a..8f88965 100644 --- a/src/com/jsyn/unitgen/FourWayFade.java +++ b/src/main/java/com/jsyn/unitgen/FourWayFade.java @@ -24,7 +24,7 @@ import com.jsyn.ports.UnitOutputPort; * <P> * Mix inputs 0-3 based on the value of two fade ports. You can think of the four inputs arranged * clockwise as follows. - * <P> + * </P> * * <PRE> * input[0] ---- input[1] diff --git a/src/com/jsyn/unitgen/FunctionEvaluator.java b/src/main/java/com/jsyn/unitgen/FunctionEvaluator.java index 0cc0c83..0cc0c83 100644 --- a/src/com/jsyn/unitgen/FunctionEvaluator.java +++ b/src/main/java/com/jsyn/unitgen/FunctionEvaluator.java diff --git a/src/com/jsyn/unitgen/FunctionOscillator.java b/src/main/java/com/jsyn/unitgen/FunctionOscillator.java index 30d32d5..30d32d5 100644 --- a/src/com/jsyn/unitgen/FunctionOscillator.java +++ b/src/main/java/com/jsyn/unitgen/FunctionOscillator.java diff --git a/src/com/jsyn/unitgen/Grain.java b/src/main/java/com/jsyn/unitgen/Grain.java index 812061c..812061c 100644 --- a/src/com/jsyn/unitgen/Grain.java +++ b/src/main/java/com/jsyn/unitgen/Grain.java diff --git a/src/com/jsyn/unitgen/GrainCommon.java b/src/main/java/com/jsyn/unitgen/GrainCommon.java index a7a04fc..a7a04fc 100644 --- a/src/com/jsyn/unitgen/GrainCommon.java +++ b/src/main/java/com/jsyn/unitgen/GrainCommon.java diff --git a/src/com/jsyn/unitgen/GrainEnvelope.java b/src/main/java/com/jsyn/unitgen/GrainEnvelope.java index e6ff24c..e6ff24c 100644 --- a/src/com/jsyn/unitgen/GrainEnvelope.java +++ b/src/main/java/com/jsyn/unitgen/GrainEnvelope.java diff --git a/src/com/jsyn/unitgen/GrainFarm.java b/src/main/java/com/jsyn/unitgen/GrainFarm.java index 78179bc..78179bc 100644 --- a/src/com/jsyn/unitgen/GrainFarm.java +++ b/src/main/java/com/jsyn/unitgen/GrainFarm.java diff --git a/src/com/jsyn/unitgen/GrainScheduler.java b/src/main/java/com/jsyn/unitgen/GrainScheduler.java index df9c25e..df9c25e 100644 --- a/src/com/jsyn/unitgen/GrainScheduler.java +++ b/src/main/java/com/jsyn/unitgen/GrainScheduler.java diff --git a/src/com/jsyn/unitgen/GrainSource.java b/src/main/java/com/jsyn/unitgen/GrainSource.java index 1d5c522..1d5c522 100644 --- a/src/com/jsyn/unitgen/GrainSource.java +++ b/src/main/java/com/jsyn/unitgen/GrainSource.java diff --git a/src/com/jsyn/unitgen/GrainSourceSine.java b/src/main/java/com/jsyn/unitgen/GrainSourceSine.java index 0af9cbd..0af9cbd 100644 --- a/src/com/jsyn/unitgen/GrainSourceSine.java +++ b/src/main/java/com/jsyn/unitgen/GrainSourceSine.java diff --git a/src/com/jsyn/unitgen/IFFT.java b/src/main/java/com/jsyn/unitgen/IFFT.java index 307acd2..307acd2 100644 --- a/src/com/jsyn/unitgen/IFFT.java +++ b/src/main/java/com/jsyn/unitgen/IFFT.java diff --git a/src/com/jsyn/unitgen/ImpulseOscillator.java b/src/main/java/com/jsyn/unitgen/ImpulseOscillator.java index 8c676f3..8c676f3 100644 --- a/src/com/jsyn/unitgen/ImpulseOscillator.java +++ b/src/main/java/com/jsyn/unitgen/ImpulseOscillator.java diff --git a/src/com/jsyn/unitgen/ImpulseOscillatorBL.java b/src/main/java/com/jsyn/unitgen/ImpulseOscillatorBL.java index 23686b8..23686b8 100644 --- a/src/com/jsyn/unitgen/ImpulseOscillatorBL.java +++ b/src/main/java/com/jsyn/unitgen/ImpulseOscillatorBL.java diff --git a/src/com/jsyn/unitgen/Integrate.java b/src/main/java/com/jsyn/unitgen/Integrate.java index b5beea9..50831d2 100644 --- a/src/com/jsyn/unitgen/Integrate.java +++ b/src/main/java/com/jsyn/unitgen/Integrate.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,8 +25,8 @@ import com.jsyn.ports.UnitOutputPort; * Output accumulated sum of the input signal. This can be used to transform one signal into * another, or to generate ramps between the limits by setting the input signal positive or * negative. For a "leaky integrator" use a FilterOnePoleOneZero. - * <P> - * + * </P> + * * <pre> * output = output + input; * if (output < lowerLimit) @@ -34,7 +34,7 @@ import com.jsyn.ports.UnitOutputPort; * else if (output > upperLimit) * output = upperLimit; * </pre> - * + * * @author (C) 1997-2011 Phil Burk, Mobileer Inc * @see FilterOnePoleOneZero */ diff --git a/src/com/jsyn/unitgen/InterpolatingDelay.java b/src/main/java/com/jsyn/unitgen/InterpolatingDelay.java index 24de4f9..24de4f9 100644 --- a/src/com/jsyn/unitgen/InterpolatingDelay.java +++ b/src/main/java/com/jsyn/unitgen/InterpolatingDelay.java diff --git a/src/com/jsyn/unitgen/Latch.java b/src/main/java/com/jsyn/unitgen/Latch.java index 0518f69..0518f69 100644 --- a/src/com/jsyn/unitgen/Latch.java +++ b/src/main/java/com/jsyn/unitgen/Latch.java diff --git a/src/com/jsyn/unitgen/LatchZeroCrossing.java b/src/main/java/com/jsyn/unitgen/LatchZeroCrossing.java index 9e6c011..9e6c011 100644 --- a/src/com/jsyn/unitgen/LatchZeroCrossing.java +++ b/src/main/java/com/jsyn/unitgen/LatchZeroCrossing.java diff --git a/src/com/jsyn/unitgen/LineIn.java b/src/main/java/com/jsyn/unitgen/LineIn.java index aeef965..aeef965 100644 --- a/src/com/jsyn/unitgen/LineIn.java +++ b/src/main/java/com/jsyn/unitgen/LineIn.java diff --git a/src/com/jsyn/unitgen/LineOut.java b/src/main/java/com/jsyn/unitgen/LineOut.java index 29c8ce7..29c8ce7 100644 --- a/src/com/jsyn/unitgen/LineOut.java +++ b/src/main/java/com/jsyn/unitgen/LineOut.java diff --git a/src/com/jsyn/unitgen/LinearRamp.java b/src/main/java/com/jsyn/unitgen/LinearRamp.java index cad53d5..cad53d5 100644 --- a/src/com/jsyn/unitgen/LinearRamp.java +++ b/src/main/java/com/jsyn/unitgen/LinearRamp.java diff --git a/src/com/jsyn/unitgen/Maximum.java b/src/main/java/com/jsyn/unitgen/Maximum.java index 296e5da..296e5da 100644 --- a/src/com/jsyn/unitgen/Maximum.java +++ b/src/main/java/com/jsyn/unitgen/Maximum.java diff --git a/src/com/jsyn/unitgen/Minimum.java b/src/main/java/com/jsyn/unitgen/Minimum.java index 046387e..046387e 100644 --- a/src/com/jsyn/unitgen/Minimum.java +++ b/src/main/java/com/jsyn/unitgen/Minimum.java diff --git a/src/com/jsyn/unitgen/MixerMono.java b/src/main/java/com/jsyn/unitgen/MixerMono.java index f4c7d7d..f4c7d7d 100644 --- a/src/com/jsyn/unitgen/MixerMono.java +++ b/src/main/java/com/jsyn/unitgen/MixerMono.java diff --git a/src/com/jsyn/unitgen/MixerMonoRamped.java b/src/main/java/com/jsyn/unitgen/MixerMonoRamped.java index 30f5342..30f5342 100644 --- a/src/com/jsyn/unitgen/MixerMonoRamped.java +++ b/src/main/java/com/jsyn/unitgen/MixerMonoRamped.java diff --git a/src/com/jsyn/unitgen/MixerStereo.java b/src/main/java/com/jsyn/unitgen/MixerStereo.java index 218546e..218546e 100644 --- a/src/com/jsyn/unitgen/MixerStereo.java +++ b/src/main/java/com/jsyn/unitgen/MixerStereo.java diff --git a/src/com/jsyn/unitgen/MixerStereoRamped.java b/src/main/java/com/jsyn/unitgen/MixerStereoRamped.java index 6f3bfcc..6f3bfcc 100644 --- a/src/com/jsyn/unitgen/MixerStereoRamped.java +++ b/src/main/java/com/jsyn/unitgen/MixerStereoRamped.java diff --git a/src/com/jsyn/unitgen/MonoStreamWriter.java b/src/main/java/com/jsyn/unitgen/MonoStreamWriter.java index 283af81..0fb6f40 100644 --- a/src/com/jsyn/unitgen/MonoStreamWriter.java +++ b/src/main/java/com/jsyn/unitgen/MonoStreamWriter.java @@ -41,7 +41,7 @@ public class MonoStreamWriter extends UnitStreamWriter { int count = limit - start; try { output.write(inputs, start, count); - } catch (IOException e) { + } catch (IOException ignored) { } } } diff --git a/src/com/jsyn/unitgen/MorphingOscillatorBL.java b/src/main/java/com/jsyn/unitgen/MorphingOscillatorBL.java index 7ca440d..7ca440d 100644 --- a/src/com/jsyn/unitgen/MorphingOscillatorBL.java +++ b/src/main/java/com/jsyn/unitgen/MorphingOscillatorBL.java diff --git a/src/com/jsyn/unitgen/MultiPassThrough.java b/src/main/java/com/jsyn/unitgen/MultiPassThrough.java index 9125fc3..9125fc3 100644 --- a/src/com/jsyn/unitgen/MultiPassThrough.java +++ b/src/main/java/com/jsyn/unitgen/MultiPassThrough.java diff --git a/src/com/jsyn/unitgen/Multiply.java b/src/main/java/com/jsyn/unitgen/Multiply.java index ded7646..ded7646 100644 --- a/src/com/jsyn/unitgen/Multiply.java +++ b/src/main/java/com/jsyn/unitgen/Multiply.java diff --git a/src/com/jsyn/unitgen/MultiplyAdd.java b/src/main/java/com/jsyn/unitgen/MultiplyAdd.java index adbee6c..adbee6c 100644 --- a/src/com/jsyn/unitgen/MultiplyAdd.java +++ b/src/main/java/com/jsyn/unitgen/MultiplyAdd.java diff --git a/src/com/jsyn/unitgen/Pan.java b/src/main/java/com/jsyn/unitgen/Pan.java index bc90984..bc90984 100644 --- a/src/com/jsyn/unitgen/Pan.java +++ b/src/main/java/com/jsyn/unitgen/Pan.java diff --git a/src/com/jsyn/unitgen/PanControl.java b/src/main/java/com/jsyn/unitgen/PanControl.java index 63bddd8..63bddd8 100644 --- a/src/com/jsyn/unitgen/PanControl.java +++ b/src/main/java/com/jsyn/unitgen/PanControl.java diff --git a/src/com/jsyn/unitgen/ParabolicEnvelope.java b/src/main/java/com/jsyn/unitgen/ParabolicEnvelope.java index 6de97d9..6de97d9 100644 --- a/src/com/jsyn/unitgen/ParabolicEnvelope.java +++ b/src/main/java/com/jsyn/unitgen/ParabolicEnvelope.java diff --git a/src/com/jsyn/unitgen/PassThrough.java b/src/main/java/com/jsyn/unitgen/PassThrough.java index 8ac0b93..8ac0b93 100644 --- a/src/com/jsyn/unitgen/PassThrough.java +++ b/src/main/java/com/jsyn/unitgen/PassThrough.java diff --git a/src/com/jsyn/unitgen/PeakFollower.java b/src/main/java/com/jsyn/unitgen/PeakFollower.java index 7bf0508..7bf0508 100644 --- a/src/com/jsyn/unitgen/PeakFollower.java +++ b/src/main/java/com/jsyn/unitgen/PeakFollower.java diff --git a/src/com/jsyn/unitgen/PhaseShifter.java b/src/main/java/com/jsyn/unitgen/PhaseShifter.java index 4b17245..4b17245 100644 --- a/src/com/jsyn/unitgen/PhaseShifter.java +++ b/src/main/java/com/jsyn/unitgen/PhaseShifter.java diff --git a/src/com/jsyn/unitgen/PinkNoise.java b/src/main/java/com/jsyn/unitgen/PinkNoise.java index 84aa2f2..84aa2f2 100644 --- a/src/com/jsyn/unitgen/PinkNoise.java +++ b/src/main/java/com/jsyn/unitgen/PinkNoise.java diff --git a/src/com/jsyn/unitgen/PitchDetector.java b/src/main/java/com/jsyn/unitgen/PitchDetector.java index da6a0e3..ff44c93 100644 --- a/src/com/jsyn/unitgen/PitchDetector.java +++ b/src/main/java/com/jsyn/unitgen/PitchDetector.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,8 @@ import com.jsyn.ports.UnitInputPort; import com.jsyn.ports.UnitOutputPort; import com.jsyn.util.AutoCorrelator; import com.jsyn.util.SignalCorrelator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Estimate the fundamental frequency of a monophonic signal. Analyzes an input signal and outputs @@ -28,10 +30,13 @@ import com.jsyn.util.SignalCorrelator; * the period. You can use a CompareUnit and a LatchUnit to hold values that you are confident of. * <P> * Note that a stable monophonic signal is required for accurate pitch tracking. - * + * * @author (C) 2012 Phil Burk, Mobileer Inc */ public class PitchDetector extends UnitGenerator { + + private static final Logger LOGGER = LoggerFactory.getLogger(PitchDetector.class); + public UnitInputPort input; public UnitOutputPort period; @@ -78,7 +83,7 @@ public class PitchDetector extends UnitGenerator { if (signalCorrelator.addSample(current)) { lastPeriod = signalCorrelator.getPeriod(); if (lastPeriod < 0.1) { - System.out.println("ILLEGAL PERIOD"); + LOGGER.debug("ILLEGAL PERIOD"); } double currentFrequency = getFrameRate() / (lastPeriod + 0); double confidence = signalCorrelator.getConfidence(); @@ -105,7 +110,7 @@ public class PitchDetector extends UnitGenerator { /** * For debugging only. - * + * * @return internal array of correlation results. */ public float[] getDiffs() { diff --git a/src/com/jsyn/unitgen/PitchToFrequency.java b/src/main/java/com/jsyn/unitgen/PitchToFrequency.java index 9086749..9086749 100644 --- a/src/com/jsyn/unitgen/PitchToFrequency.java +++ b/src/main/java/com/jsyn/unitgen/PitchToFrequency.java diff --git a/src/com/jsyn/unitgen/PowerOfTwo.java b/src/main/java/com/jsyn/unitgen/PowerOfTwo.java index 5916860..5916860 100644 --- a/src/com/jsyn/unitgen/PowerOfTwo.java +++ b/src/main/java/com/jsyn/unitgen/PowerOfTwo.java diff --git a/src/com/jsyn/unitgen/PulseOscillator.java b/src/main/java/com/jsyn/unitgen/PulseOscillator.java index 5ac7352..5ac7352 100644 --- a/src/com/jsyn/unitgen/PulseOscillator.java +++ b/src/main/java/com/jsyn/unitgen/PulseOscillator.java diff --git a/src/com/jsyn/unitgen/PulseOscillatorBL.java b/src/main/java/com/jsyn/unitgen/PulseOscillatorBL.java index c0e234c..c0e234c 100644 --- a/src/com/jsyn/unitgen/PulseOscillatorBL.java +++ b/src/main/java/com/jsyn/unitgen/PulseOscillatorBL.java diff --git a/src/com/jsyn/unitgen/RaisedCosineEnvelope.java b/src/main/java/com/jsyn/unitgen/RaisedCosineEnvelope.java index c32417c..c32417c 100644 --- a/src/com/jsyn/unitgen/RaisedCosineEnvelope.java +++ b/src/main/java/com/jsyn/unitgen/RaisedCosineEnvelope.java diff --git a/src/com/jsyn/unitgen/RangeConverter.java b/src/main/java/com/jsyn/unitgen/RangeConverter.java index ae94b0f..ae94b0f 100644 --- a/src/com/jsyn/unitgen/RangeConverter.java +++ b/src/main/java/com/jsyn/unitgen/RangeConverter.java diff --git a/src/com/jsyn/unitgen/RectangularWindow.java b/src/main/java/com/jsyn/unitgen/RectangularWindow.java index d61f763..d61f763 100644 --- a/src/com/jsyn/unitgen/RectangularWindow.java +++ b/src/main/java/com/jsyn/unitgen/RectangularWindow.java diff --git a/src/com/jsyn/unitgen/RedNoise.java b/src/main/java/com/jsyn/unitgen/RedNoise.java index d3e4321..d3e4321 100644 --- a/src/com/jsyn/unitgen/RedNoise.java +++ b/src/main/java/com/jsyn/unitgen/RedNoise.java diff --git a/src/com/jsyn/unitgen/SampleGrainFarm.java b/src/main/java/com/jsyn/unitgen/SampleGrainFarm.java index 3f908d6..3f908d6 100644 --- a/src/com/jsyn/unitgen/SampleGrainFarm.java +++ b/src/main/java/com/jsyn/unitgen/SampleGrainFarm.java diff --git a/src/com/jsyn/unitgen/SampleGrainSource.java b/src/main/java/com/jsyn/unitgen/SampleGrainSource.java index f33817f..f33817f 100644 --- a/src/com/jsyn/unitgen/SampleGrainSource.java +++ b/src/main/java/com/jsyn/unitgen/SampleGrainSource.java diff --git a/src/com/jsyn/unitgen/SawtoothOscillator.java b/src/main/java/com/jsyn/unitgen/SawtoothOscillator.java index 1b3dead..1b3dead 100644 --- a/src/com/jsyn/unitgen/SawtoothOscillator.java +++ b/src/main/java/com/jsyn/unitgen/SawtoothOscillator.java diff --git a/src/com/jsyn/unitgen/SawtoothOscillatorBL.java b/src/main/java/com/jsyn/unitgen/SawtoothOscillatorBL.java index 8b58f6c..8b58f6c 100644 --- a/src/com/jsyn/unitgen/SawtoothOscillatorBL.java +++ b/src/main/java/com/jsyn/unitgen/SawtoothOscillatorBL.java diff --git a/src/com/jsyn/unitgen/SawtoothOscillatorDPW.java b/src/main/java/com/jsyn/unitgen/SawtoothOscillatorDPW.java index 27d0c5a..27d0c5a 100644 --- a/src/com/jsyn/unitgen/SawtoothOscillatorDPW.java +++ b/src/main/java/com/jsyn/unitgen/SawtoothOscillatorDPW.java diff --git a/src/com/jsyn/unitgen/SchmidtTrigger.java b/src/main/java/com/jsyn/unitgen/SchmidtTrigger.java index 64129ff..64129ff 100644 --- a/src/com/jsyn/unitgen/SchmidtTrigger.java +++ b/src/main/java/com/jsyn/unitgen/SchmidtTrigger.java diff --git a/src/com/jsyn/unitgen/Select.java b/src/main/java/com/jsyn/unitgen/Select.java index 6d8792e..6d8792e 100644 --- a/src/com/jsyn/unitgen/Select.java +++ b/src/main/java/com/jsyn/unitgen/Select.java diff --git a/src/com/jsyn/unitgen/SequentialDataReader.java b/src/main/java/com/jsyn/unitgen/SequentialDataReader.java index 901767b..901767b 100644 --- a/src/com/jsyn/unitgen/SequentialDataReader.java +++ b/src/main/java/com/jsyn/unitgen/SequentialDataReader.java diff --git a/src/com/jsyn/unitgen/SequentialDataWriter.java b/src/main/java/com/jsyn/unitgen/SequentialDataWriter.java index cb3bb11..cb3bb11 100644 --- a/src/com/jsyn/unitgen/SequentialDataWriter.java +++ b/src/main/java/com/jsyn/unitgen/SequentialDataWriter.java diff --git a/src/com/jsyn/unitgen/SineOscillator.java b/src/main/java/com/jsyn/unitgen/SineOscillator.java index 8c49ead..8112e46 100644 --- a/src/com/jsyn/unitgen/SineOscillator.java +++ b/src/main/java/com/jsyn/unitgen/SineOscillator.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +19,7 @@ package com.jsyn.unitgen; /** * Sine oscillator generates a frequency controlled sine wave. It is implemented using a fast Taylor * expansion. - * + * * @author Phil Burk (C) 2009 Mobileer Inc */ public class SineOscillator extends UnitOscillator { @@ -60,7 +60,7 @@ public class SineOscillator extends UnitOscillator { /** * Calculate sine using Taylor expansion. Do not use values outside the range. - * + * * @param currentPhase in the range of -1.0 to +1.0 for one cycle */ public static double fastSin(double currentPhase) { @@ -78,8 +78,7 @@ public class SineOscillator extends UnitOscillator { double x = yp * Math.PI; double x2 = (x * x); /* Taylor expansion out to x**11/11! factored into multiply-adds */ - double fastsin = x + return x * (x2 * (x2 * (x2 * (x2 * ((x2 * (-IF11)) + IF9) - IF7) + IF5) - IF3) + 1); - return fastsin; } } diff --git a/src/com/jsyn/unitgen/SineOscillatorPhaseModulated.java b/src/main/java/com/jsyn/unitgen/SineOscillatorPhaseModulated.java index 7631dff..7631dff 100644 --- a/src/com/jsyn/unitgen/SineOscillatorPhaseModulated.java +++ b/src/main/java/com/jsyn/unitgen/SineOscillatorPhaseModulated.java diff --git a/src/com/jsyn/unitgen/SpectralFFT.java b/src/main/java/com/jsyn/unitgen/SpectralFFT.java index f3e881a..f3e881a 100644 --- a/src/com/jsyn/unitgen/SpectralFFT.java +++ b/src/main/java/com/jsyn/unitgen/SpectralFFT.java diff --git a/src/com/jsyn/unitgen/SpectralFilter.java b/src/main/java/com/jsyn/unitgen/SpectralFilter.java index 758c8e7..758c8e7 100644 --- a/src/com/jsyn/unitgen/SpectralFilter.java +++ b/src/main/java/com/jsyn/unitgen/SpectralFilter.java diff --git a/src/com/jsyn/unitgen/SpectralIFFT.java b/src/main/java/com/jsyn/unitgen/SpectralIFFT.java index c040e52..c040e52 100644 --- a/src/com/jsyn/unitgen/SpectralIFFT.java +++ b/src/main/java/com/jsyn/unitgen/SpectralIFFT.java diff --git a/src/com/jsyn/unitgen/SpectralProcessor.java b/src/main/java/com/jsyn/unitgen/SpectralProcessor.java index de96877..de96877 100644 --- a/src/com/jsyn/unitgen/SpectralProcessor.java +++ b/src/main/java/com/jsyn/unitgen/SpectralProcessor.java diff --git a/src/com/jsyn/unitgen/SquareOscillator.java b/src/main/java/com/jsyn/unitgen/SquareOscillator.java index aaca2d0..aaca2d0 100644 --- a/src/com/jsyn/unitgen/SquareOscillator.java +++ b/src/main/java/com/jsyn/unitgen/SquareOscillator.java diff --git a/src/com/jsyn/unitgen/SquareOscillatorBL.java b/src/main/java/com/jsyn/unitgen/SquareOscillatorBL.java index cb9e141..cb9e141 100644 --- a/src/com/jsyn/unitgen/SquareOscillatorBL.java +++ b/src/main/java/com/jsyn/unitgen/SquareOscillatorBL.java diff --git a/src/com/jsyn/unitgen/StereoStreamWriter.java b/src/main/java/com/jsyn/unitgen/StereoStreamWriter.java index b387836..b387836 100644 --- a/src/com/jsyn/unitgen/StereoStreamWriter.java +++ b/src/main/java/com/jsyn/unitgen/StereoStreamWriter.java diff --git a/src/com/jsyn/unitgen/StochasticGrainScheduler.java b/src/main/java/com/jsyn/unitgen/StochasticGrainScheduler.java index 1f79877..1f79877 100644 --- a/src/com/jsyn/unitgen/StochasticGrainScheduler.java +++ b/src/main/java/com/jsyn/unitgen/StochasticGrainScheduler.java diff --git a/src/com/jsyn/unitgen/Subtract.java b/src/main/java/com/jsyn/unitgen/Subtract.java index d9ca035..d9ca035 100644 --- a/src/com/jsyn/unitgen/Subtract.java +++ b/src/main/java/com/jsyn/unitgen/Subtract.java diff --git a/src/com/jsyn/unitgen/TriangleOscillator.java b/src/main/java/com/jsyn/unitgen/TriangleOscillator.java index ada2d6e..ada2d6e 100644 --- a/src/com/jsyn/unitgen/TriangleOscillator.java +++ b/src/main/java/com/jsyn/unitgen/TriangleOscillator.java diff --git a/src/com/jsyn/unitgen/TunableFilter.java b/src/main/java/com/jsyn/unitgen/TunableFilter.java index d2c9f66..d2c9f66 100644 --- a/src/com/jsyn/unitgen/TunableFilter.java +++ b/src/main/java/com/jsyn/unitgen/TunableFilter.java diff --git a/src/com/jsyn/unitgen/TwoInDualOut.java b/src/main/java/com/jsyn/unitgen/TwoInDualOut.java index a8fea48..a8fea48 100644 --- a/src/com/jsyn/unitgen/TwoInDualOut.java +++ b/src/main/java/com/jsyn/unitgen/TwoInDualOut.java diff --git a/src/com/jsyn/unitgen/UnitBinaryOperator.java b/src/main/java/com/jsyn/unitgen/UnitBinaryOperator.java index c5675ff..c5675ff 100644 --- a/src/com/jsyn/unitgen/UnitBinaryOperator.java +++ b/src/main/java/com/jsyn/unitgen/UnitBinaryOperator.java diff --git a/src/com/jsyn/unitgen/UnitFilter.java b/src/main/java/com/jsyn/unitgen/UnitFilter.java index 49976ba..49976ba 100644 --- a/src/com/jsyn/unitgen/UnitFilter.java +++ b/src/main/java/com/jsyn/unitgen/UnitFilter.java diff --git a/src/com/jsyn/unitgen/UnitGate.java b/src/main/java/com/jsyn/unitgen/UnitGate.java index 59144c2..59144c2 100644 --- a/src/com/jsyn/unitgen/UnitGate.java +++ b/src/main/java/com/jsyn/unitgen/UnitGate.java diff --git a/src/com/jsyn/unitgen/UnitGenerator.java b/src/main/java/com/jsyn/unitgen/UnitGenerator.java index 1e87ae6..7aacaf1 100644 --- a/src/com/jsyn/unitgen/UnitGenerator.java +++ b/src/main/java/com/jsyn/unitgen/UnitGenerator.java @@ -19,7 +19,6 @@ package com.jsyn.unitgen; import java.io.PrintStream; import java.util.Collection; import java.util.LinkedHashMap; -import java.util.logging.Logger; import com.jsyn.Synthesizer; import com.jsyn.engine.SynthesisEngine; @@ -28,6 +27,8 @@ import com.jsyn.ports.UnitInputPort; import com.jsyn.ports.UnitOutputPort; import com.jsyn.ports.UnitPort; import com.softsynth.shared.time.TimeStamp; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Base class for all unit generators. @@ -35,6 +36,9 @@ import com.softsynth.shared.time.TimeStamp; * @author Phil Burk (C) 2009 Mobileer Inc */ public abstract class UnitGenerator { + + private static final Logger LOGGER = LoggerFactory.getLogger(UnitGenerator.class); + protected static final double VERY_SMALL_FLOAT = 1.0e-26; // Some common port names. @@ -60,8 +64,6 @@ public abstract class UnitGenerator { private static int nextId; private final int id = nextId++; - static Logger logger = Logger.getLogger(UnitGenerator.class.getName()); - public int getId() { return id; } @@ -145,7 +147,7 @@ public abstract class UnitGenerator { while (unit.circuit != null) { unit = unit.circuit; } - logger.fine("getTopUnit " + this + " => " + unit); + LOGGER.debug("getTopUnit " + this + " => " + unit); return unit; } @@ -197,7 +199,7 @@ public abstract class UnitGenerator { if ((this.circuit != null) && (circuit != null)) { throw new RuntimeException("Unit is already in a circuit."); } - // logger.info( "setCircuit in unit " + this + " with circuit " + circuit ); + // LOGGER.info( "setCircuit in unit " + this + " with circuit " + circuit ); this.circuit = circuit; } @@ -233,7 +235,7 @@ public abstract class UnitGenerator { * * @param enabled * @see UnitGate#setupAutoDisable(UnitGenerator) - * @see start + * @see #start() */ public void setEnabled(boolean enabled) { this.enabled = enabled; @@ -260,7 +262,7 @@ public abstract class UnitGenerator { * units are connected in a circle then this will be detected and the infinite recursion will be * blocked. * - * @see setEnabled + * @see #setEnabled(boolean) */ public void start() { if (getSynthesisEngine() == null) { @@ -274,7 +276,7 @@ public abstract class UnitGenerator { * Start a unit at the specified time. * * @param time - * @see start + * @see #start() */ public void start(double time) { start(new TimeStamp(time)); @@ -284,7 +286,7 @@ public abstract class UnitGenerator { * Start a unit at the specified time. * * @param timeStamp - * @see start + * @see #start() */ public void start(TimeStamp timeStamp) { if (getSynthesisEngine() == null) { @@ -298,7 +300,7 @@ public abstract class UnitGenerator { * Stop a unit at the specified time. * * @param time - * @see start + * @see #start() */ public void stop(double time) { stop(new TimeStamp(time)); @@ -328,9 +330,9 @@ public abstract class UnitGenerator { /** Needed by UnitVoice */ public void setPort(String portName, double value, TimeStamp timeStamp) { UnitInputPort port = (UnitInputPort) getPortByName(portName); - // System.out.println("setPort " + port ); + // LOGGER.debug("setPort " + port ); if (port == null) { - logger.warning("port was null for name " + portName + ", " + this.getClass().getName()); + LOGGER.warn("port was null for name " + portName + ", " + this.getClass().getName()); } else { port.set(value, timeStamp); } diff --git a/src/com/jsyn/unitgen/UnitOscillator.java b/src/main/java/com/jsyn/unitgen/UnitOscillator.java index 5d4c6fa..5d4c6fa 100644 --- a/src/com/jsyn/unitgen/UnitOscillator.java +++ b/src/main/java/com/jsyn/unitgen/UnitOscillator.java diff --git a/src/com/jsyn/unitgen/UnitSink.java b/src/main/java/com/jsyn/unitgen/UnitSink.java index 3e0f55e..3e0f55e 100644 --- a/src/com/jsyn/unitgen/UnitSink.java +++ b/src/main/java/com/jsyn/unitgen/UnitSink.java diff --git a/src/com/jsyn/unitgen/UnitSource.java b/src/main/java/com/jsyn/unitgen/UnitSource.java index 5ee8134..5ee8134 100644 --- a/src/com/jsyn/unitgen/UnitSource.java +++ b/src/main/java/com/jsyn/unitgen/UnitSource.java diff --git a/src/com/jsyn/unitgen/UnitStreamWriter.java b/src/main/java/com/jsyn/unitgen/UnitStreamWriter.java index 0c5bd8b..0c5bd8b 100644 --- a/src/com/jsyn/unitgen/UnitStreamWriter.java +++ b/src/main/java/com/jsyn/unitgen/UnitStreamWriter.java diff --git a/src/com/jsyn/unitgen/UnitVoice.java b/src/main/java/com/jsyn/unitgen/UnitVoice.java index 3f5e6ef..3f5e6ef 100644 --- a/src/com/jsyn/unitgen/UnitVoice.java +++ b/src/main/java/com/jsyn/unitgen/UnitVoice.java diff --git a/src/com/jsyn/unitgen/Unzipper.java b/src/main/java/com/jsyn/unitgen/Unzipper.java index c776ffb..c776ffb 100644 --- a/src/com/jsyn/unitgen/Unzipper.java +++ b/src/main/java/com/jsyn/unitgen/Unzipper.java diff --git a/src/com/jsyn/unitgen/VariableRateDataReader.java b/src/main/java/com/jsyn/unitgen/VariableRateDataReader.java index 2ef163c..2ef163c 100644 --- a/src/com/jsyn/unitgen/VariableRateDataReader.java +++ b/src/main/java/com/jsyn/unitgen/VariableRateDataReader.java diff --git a/src/com/jsyn/unitgen/VariableRateMonoReader.java b/src/main/java/com/jsyn/unitgen/VariableRateMonoReader.java index 52b7f1e..52b7f1e 100644 --- a/src/com/jsyn/unitgen/VariableRateMonoReader.java +++ b/src/main/java/com/jsyn/unitgen/VariableRateMonoReader.java diff --git a/src/com/jsyn/unitgen/VariableRateStereoReader.java b/src/main/java/com/jsyn/unitgen/VariableRateStereoReader.java index 0f9fce8..0f9fce8 100644 --- a/src/com/jsyn/unitgen/VariableRateStereoReader.java +++ b/src/main/java/com/jsyn/unitgen/VariableRateStereoReader.java diff --git a/src/com/jsyn/unitgen/WhiteNoise.java b/src/main/java/com/jsyn/unitgen/WhiteNoise.java index b708e92..b708e92 100644 --- a/src/com/jsyn/unitgen/WhiteNoise.java +++ b/src/main/java/com/jsyn/unitgen/WhiteNoise.java diff --git a/src/com/jsyn/unitgen/ZeroCrossingCounter.java b/src/main/java/com/jsyn/unitgen/ZeroCrossingCounter.java index 6cd36ea..6cd36ea 100644 --- a/src/com/jsyn/unitgen/ZeroCrossingCounter.java +++ b/src/main/java/com/jsyn/unitgen/ZeroCrossingCounter.java diff --git a/src/com/jsyn/util/AudioSampleLoader.java b/src/main/java/com/jsyn/util/AudioSampleLoader.java index b665933..b665933 100644 --- a/src/com/jsyn/util/AudioSampleLoader.java +++ b/src/main/java/com/jsyn/util/AudioSampleLoader.java diff --git a/src/com/jsyn/util/AudioStreamReader.java b/src/main/java/com/jsyn/util/AudioStreamReader.java index 5a725c3..5a725c3 100644 --- a/src/com/jsyn/util/AudioStreamReader.java +++ b/src/main/java/com/jsyn/util/AudioStreamReader.java diff --git a/src/com/jsyn/util/AutoCorrelator.java b/src/main/java/com/jsyn/util/AutoCorrelator.java index 2996036..944d515 100644 --- a/src/com/jsyn/util/AutoCorrelator.java +++ b/src/main/java/com/jsyn/util/AutoCorrelator.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +20,7 @@ package com.jsyn.util; * Calculate period of a repeated waveform in an array. This algorithm is based on a normalized * auto-correlation function as dewscribed in: "A Smarter Way to Find Pitch" by Philip McLeod and * Geoff Wyvill - * + * * @author (C) 2004 Mobileer, PROPRIETARY and CONFIDENTIAL */ public class AutoCorrelator implements SignalCorrelator { @@ -84,17 +84,15 @@ public class AutoCorrelator implements SignalCorrelator { // Do correlation when we know the splitLast will wrap around. private void splitDeltaScan(int last1, int splitLast, int count, int stride) { - int c1 = splitLast; - rawDeltaScan(last1, splitLast, c1, stride); - rawDeltaScan(last1 - c1, buffer.length - 1, count - c1, stride); + rawDeltaScan(last1, splitLast, splitLast, stride); + rawDeltaScan(last1 - splitLast, buffer.length - 1, count - splitLast, stride); } private void checkDeltaScan(int last1, int last2, int count, int stride) { if (count > last2) { - int c1 = last2; // Use recursion with reverse indexes to handle a double split. - checkDeltaScan(last2, last1, c1, stride); - checkDeltaScan(buffer.length - 1, last1 - c1, count - c1, stride); + checkDeltaScan(last2, last1, last2, stride); + checkDeltaScan(buffer.length - 1, last1 - last2, count - last2, stride); } else if (count > last1) { splitDeltaScan(last2, last1, count, stride); } else { @@ -119,9 +117,8 @@ public class AutoCorrelator implements SignalCorrelator { return minimumResult; } float correction = (float) Math.pow(pitchCorrectionFactor, tau); - float result = (float) (2.0 * sumProducts / sumSquares) * correction; - return result; + return (float) (2.0 * sumProducts / sumSquares) * correction; } // Prepare for a new calculation. diff --git a/src/com/jsyn/util/Instrument.java b/src/main/java/com/jsyn/util/Instrument.java index 8a53304..8a53304 100644 --- a/src/com/jsyn/util/Instrument.java +++ b/src/main/java/com/jsyn/util/Instrument.java diff --git a/src/com/jsyn/util/InstrumentLibrary.java b/src/main/java/com/jsyn/util/InstrumentLibrary.java index 65113dc..65113dc 100644 --- a/src/com/jsyn/util/InstrumentLibrary.java +++ b/src/main/java/com/jsyn/util/InstrumentLibrary.java diff --git a/src/com/jsyn/util/JavaSoundSampleLoader.java b/src/main/java/com/jsyn/util/JavaSoundSampleLoader.java index 56a654e..56a654e 100644 --- a/src/com/jsyn/util/JavaSoundSampleLoader.java +++ b/src/main/java/com/jsyn/util/JavaSoundSampleLoader.java diff --git a/src/com/jsyn/util/JavaTools.java b/src/main/java/com/jsyn/util/JavaTools.java index 65e3dd1..570e4c4 100644 --- a/src/com/jsyn/util/JavaTools.java +++ b/src/main/java/com/jsyn/util/JavaTools.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,8 +16,13 @@ package com.jsyn.util; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class JavaTools { + private static final Logger LOGGER = LoggerFactory.getLogger(JavaTools.class); + @SuppressWarnings("rawtypes") public static Class loadClass(String className, boolean verbose) { Class newClass = null; @@ -25,7 +30,7 @@ public class JavaTools { newClass = Class.forName(className); } catch (Throwable e) { if (verbose) - System.out.println("Caught " + e); + LOGGER.debug("Caught " + e); } if (newClass == null) { try { @@ -33,7 +38,7 @@ public class JavaTools { newClass = Class.forName(className, true, systemLoader); } catch (Throwable e) { if (verbose) - System.out.println("Caught " + e); + LOGGER.debug("Caught " + e); } } return newClass; @@ -42,7 +47,7 @@ public class JavaTools { /** * First try Class.forName(). If this fails, try Class.forName() using * ClassLoader.getSystemClassLoader(). - * + * * @return Class or null */ @SuppressWarnings("rawtypes") @@ -50,7 +55,7 @@ public class JavaTools { /** * First try Class.forName(). If this fails, try Class.forName() using * ClassLoader.getSystemClassLoader(). - * + * * @return Class or null */ return loadClass(className, true); diff --git a/src/com/jsyn/util/MultiChannelSynthesizer.java b/src/main/java/com/jsyn/util/MultiChannelSynthesizer.java index b84d753..da7f6c7 100644 --- a/src/com/jsyn/util/MultiChannelSynthesizer.java +++ b/src/main/java/com/jsyn/util/MultiChannelSynthesizer.java @@ -153,7 +153,7 @@ public class MultiChannelSynthesizer { void programChange(int program) { int programWrapped = program % groupContext.voiceDescription.getPresetCount(); String name = groupContext.voiceDescription.getPresetNames()[programWrapped]; - //System.out.println("Preset[" + program + "] = " + name); + //LOGGER.debug("Preset[" + program + "] = " + name); presetIndex = programWrapped; } @@ -171,7 +171,7 @@ public class MultiChannelSynthesizer { void noteOn(int noteNumber, double amplitude, TimeStamp timeStamp) { double frequency = AudioMath.pitchToFrequency(noteNumber); - //System.out.println("noteOn(noteNumber) -> " + frequency + " Hz"); + //LOGGER.debug("noteOn(noteNumber) -> " + frequency + " Hz"); groupContext.allocator.noteOn(noteNumber, frequency, amplitude, voiceOperation, timeStamp); } @@ -337,7 +337,7 @@ public class MultiChannelSynthesizer { * @param offset ranges from -1.0 to +1.0 */ public void setPitchBend(int channel, double offset) { - //System.out.println("setPitchBend[" + channel + "] = " + offset); + //LOGGER.debug("setPitchBend[" + channel + "] = " + offset); ChannelContext channelContext = channels[channel]; channelContext.setPitchBend(offset); } diff --git a/src/com/jsyn/util/NumericOutput.java b/src/main/java/com/jsyn/util/NumericOutput.java index 79afaf1..e30975f 100644 --- a/src/com/jsyn/util/NumericOutput.java +++ b/src/main/java/com/jsyn/util/NumericOutput.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,14 +16,20 @@ package com.jsyn.util; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Formatted numeric output. Convert integers and floats to strings based on field widths and * desired decimal places. - * + * * @author Phil Burk (C) 1999 SoftSynth.com */ public class NumericOutput { + + private static final Logger LOGGER = LoggerFactory.getLogger(NumericOutput.class); + static char digitToChar(int digit) { if (digit > 9) { return (char) ('A' + digit - 10); @@ -48,9 +54,9 @@ public class NumericOutput { boolean ifNeg = false; // only do sign if decimal if (radix != 10) { - // System.out.println("MASK before : ln = " + ln ); + // LOGGER.debug("MASK before : ln = " + ln ); ln = ln & 0x00000000FFFFFFFFL; - // System.out.println("MASK after : ln = " + ln ); + // LOGGER.debug("MASK after : ln = " + ln ); } else if (ln < 0) { ifNeg = true; ln = -ln; @@ -58,7 +64,7 @@ public class NumericOutput { if (ln == 0) { buf.append('0'); } else { - // System.out.println(" ln = " + ln ); + // LOGGER.debug(" ln = " + ln ); while (ln > 0) { int rem = (int) (ln % radix); buf.append(digitToChar(rem)); @@ -85,7 +91,7 @@ public class NumericOutput { /** * Convert double to string. - * + * * @param width = minimum width of formatted string * @param places = number of digits displayed after decimal point */ @@ -95,7 +101,7 @@ public class NumericOutput { /** * Convert double to string. - * + * * @param width = minimum width of formatted string * @param places = number of digits displayed after decimal point */ @@ -141,34 +147,34 @@ public class NumericOutput { } static void testInteger(int n) { - System.out.println("Test " + n + ", 0x" + Integer.toHexString(n) + ", %" + LOGGER.debug("Test " + n + ", 0x" + Integer.toHexString(n) + ", %" + Integer.toBinaryString(n)); - System.out.println(" +,8,t,10 = " + integerToString(n, 8, true, 10)); - System.out.println(" +,8,f,10 = " + integerToString(n, 8, false, 10)); - System.out.println(" -,8,t,10 = " + integerToString(-n, 8, true, 10)); - System.out.println(" -,8,f,10 = " + integerToString(-n, 8, false, 10)); - System.out.println(" +,8,t,16 = " + integerToString(n, 8, true, 16)); - System.out.println(" +,8,f,16 = " + integerToString(n, 8, false, 16)); - System.out.println(" -,8,t,16 = " + integerToString(-n, 8, true, 16)); - System.out.println(" -,8,f,16 = " + integerToString(-n, 8, false, 16)); - System.out.println(" +,8,t, 2 = " + integerToString(n, 8, true, 2)); - System.out.println(" +,8,f, 2 = " + integerToString(n, 8, false, 2)); + LOGGER.debug(" +,8,t,10 = " + integerToString(n, 8, true, 10)); + LOGGER.debug(" +,8,f,10 = " + integerToString(n, 8, false, 10)); + LOGGER.debug(" -,8,t,10 = " + integerToString(-n, 8, true, 10)); + LOGGER.debug(" -,8,f,10 = " + integerToString(-n, 8, false, 10)); + LOGGER.debug(" +,8,t,16 = " + integerToString(n, 8, true, 16)); + LOGGER.debug(" +,8,f,16 = " + integerToString(n, 8, false, 16)); + LOGGER.debug(" -,8,t,16 = " + integerToString(-n, 8, true, 16)); + LOGGER.debug(" -,8,f,16 = " + integerToString(-n, 8, false, 16)); + LOGGER.debug(" +,8,t, 2 = " + integerToString(n, 8, true, 2)); + LOGGER.debug(" +,8,f, 2 = " + integerToString(n, 8, false, 2)); } static void testDouble(double value) { - System.out.println("Test " + value); - System.out.println(" +,5,1 = " + doubleToString(value, 5, 1)); - System.out.println(" -,5,1 = " + doubleToString(-value, 5, 1)); + LOGGER.debug("Test " + value); + LOGGER.debug(" +,5,1 = " + doubleToString(value, 5, 1)); + LOGGER.debug(" -,5,1 = " + doubleToString(-value, 5, 1)); - System.out.println(" +,14,3 = " + doubleToString(value, 14, 3)); - System.out.println(" -,14,3 = " + doubleToString(-value, 14, 3)); + LOGGER.debug(" +,14,3 = " + doubleToString(value, 14, 3)); + LOGGER.debug(" -,14,3 = " + doubleToString(-value, 14, 3)); - System.out.println(" +,6,2,true = " + doubleToString(value, 6, 2, true)); - System.out.println(" -,6,2,true = " + doubleToString(-value, 6, 2, true)); + LOGGER.debug(" +,6,2,true = " + doubleToString(value, 6, 2, true)); + LOGGER.debug(" -,6,2,true = " + doubleToString(-value, 6, 2, true)); } public static void main(String argv[]) { - System.out.println("Test NumericOutput"); + LOGGER.debug("Test NumericOutput"); testInteger(0); testInteger(1); testInteger(16); diff --git a/src/com/jsyn/util/PolyphonicInstrument.java b/src/main/java/com/jsyn/util/PolyphonicInstrument.java index 08460d0..08460d0 100644 --- a/src/com/jsyn/util/PolyphonicInstrument.java +++ b/src/main/java/com/jsyn/util/PolyphonicInstrument.java diff --git a/src/com/jsyn/util/PseudoRandom.java b/src/main/java/com/jsyn/util/PseudoRandom.java index e92b669..e92b669 100644 --- a/src/com/jsyn/util/PseudoRandom.java +++ b/src/main/java/com/jsyn/util/PseudoRandom.java diff --git a/src/com/jsyn/util/RecursiveSequenceGenerator.java b/src/main/java/com/jsyn/util/RecursiveSequenceGenerator.java index 53dbdf9..0d6e451 100644 --- a/src/com/jsyn/util/RecursiveSequenceGenerator.java +++ b/src/main/java/com/jsyn/util/RecursiveSequenceGenerator.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,17 +21,17 @@ import java.util.Random; /** * Generate a sequence of integers based on a recursive mining of previous material. Notes are * generated by one of the following formula: - * + * * <pre> * <code> * value[n] = value[n-delay] + offset; * </code> * </pre> - * + * * The parameters delay and offset are randomly generated. This algorithm was first developed in * 1977 for a class project in FORTRAN. It was ported to Forth for HMSL in the late 80's. It was * then ported to Java for JSyn in 1997. - * + * * @author Phil Burk (C) 1997,2011 Mobileer Inc */ public class RecursiveSequenceGenerator { @@ -121,7 +121,7 @@ public class RecursiveSequenceGenerator { delay = randomPowerOf2(4); calcNewOffset(); - // System.out.println("NewSeq: delay = " + delay + ", offset = " + + // LOGGER.debug("NewSeq: delay = " + delay + ", offset = " + // offset ); } @@ -181,7 +181,7 @@ public class RecursiveSequenceGenerator { } calcNewOffset(); timeout--; - // System.out.println("NextVal = " + nextVal + ", offset = " + + // LOGGER.debug("NextVal = " + nextVal + ", offset = " + // offset ); } if (timeout <= 0) { @@ -198,7 +198,7 @@ public class RecursiveSequenceGenerator { if (cursor >= values.length) cursor = 0; - // System.out.println("nextVal = " + nextVal ); + // LOGGER.debug("nextVal = " + nextVal ); return playIt ? nextVal : -1; } diff --git a/src/com/jsyn/util/SampleLoader.java b/src/main/java/com/jsyn/util/SampleLoader.java index 170b4cb..170b4cb 100644 --- a/src/com/jsyn/util/SampleLoader.java +++ b/src/main/java/com/jsyn/util/SampleLoader.java diff --git a/src/com/jsyn/util/SignalCorrelator.java b/src/main/java/com/jsyn/util/SignalCorrelator.java index ebdd46b..ebdd46b 100644 --- a/src/com/jsyn/util/SignalCorrelator.java +++ b/src/main/java/com/jsyn/util/SignalCorrelator.java diff --git a/src/com/jsyn/util/StreamingThread.java b/src/main/java/com/jsyn/util/StreamingThread.java index 682f476..682f476 100644 --- a/src/com/jsyn/util/StreamingThread.java +++ b/src/main/java/com/jsyn/util/StreamingThread.java diff --git a/src/com/jsyn/util/TransportListener.java b/src/main/java/com/jsyn/util/TransportListener.java index 3c8b048..3c8b048 100644 --- a/src/com/jsyn/util/TransportListener.java +++ b/src/main/java/com/jsyn/util/TransportListener.java diff --git a/src/com/jsyn/util/TransportModel.java b/src/main/java/com/jsyn/util/TransportModel.java index bcc75be..bcc75be 100644 --- a/src/com/jsyn/util/TransportModel.java +++ b/src/main/java/com/jsyn/util/TransportModel.java diff --git a/src/com/jsyn/util/VoiceAllocator.java b/src/main/java/com/jsyn/util/VoiceAllocator.java index f20f7a5..f20f7a5 100644 --- a/src/com/jsyn/util/VoiceAllocator.java +++ b/src/main/java/com/jsyn/util/VoiceAllocator.java diff --git a/src/com/jsyn/util/VoiceDescription.java b/src/main/java/com/jsyn/util/VoiceDescription.java index b7be044..b7be044 100644 --- a/src/com/jsyn/util/VoiceDescription.java +++ b/src/main/java/com/jsyn/util/VoiceDescription.java diff --git a/src/com/jsyn/util/VoiceOperation.java b/src/main/java/com/jsyn/util/VoiceOperation.java index cd3b48e..cd3b48e 100644 --- a/src/com/jsyn/util/VoiceOperation.java +++ b/src/main/java/com/jsyn/util/VoiceOperation.java diff --git a/src/com/jsyn/util/WaveFileWriter.java b/src/main/java/com/jsyn/util/WaveFileWriter.java index 32e9995..32e9995 100644 --- a/src/com/jsyn/util/WaveFileWriter.java +++ b/src/main/java/com/jsyn/util/WaveFileWriter.java diff --git a/src/com/jsyn/util/WaveRecorder.java b/src/main/java/com/jsyn/util/WaveRecorder.java index 059863b..8008d1d 100644 --- a/src/com/jsyn/util/WaveRecorder.java +++ b/src/main/java/com/jsyn/util/WaveRecorder.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import com.jsyn.ports.UnitInputPort; /** * Connect a unit generator to the input. Then start() recording. The signal will be written to a * WAV format file that can be read by other programs. - * + * * @author Phil Burk (C) 2011 Mobileer Inc */ public class WaveRecorder { @@ -39,7 +39,7 @@ public class WaveRecorder { /** * Create a stereo 16-bit recorder. - * + * * @param synth * @param outputFile * @throws FileNotFoundException @@ -89,7 +89,7 @@ public class WaveRecorder { thread.requestStop(); try { thread.join(500); - } catch (InterruptedException e) { + } catch (InterruptedException ignored) { } thread = null; } diff --git a/src/com/jsyn/util/soundfile/AIFFFileParser.java b/src/main/java/com/jsyn/util/soundfile/AIFFFileParser.java index 2b09d78..89b443c 100644 --- a/src/com/jsyn/util/soundfile/AIFFFileParser.java +++ b/src/main/java/com/jsyn/util/soundfile/AIFFFileParser.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,8 +22,13 @@ import java.io.IOException; import com.jsyn.data.FloatSample; import com.jsyn.data.SampleMarker; import com.jsyn.util.SampleLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AIFFFileParser extends AudioFileParser { + + private static final Logger LOGGER = LoggerFactory.getLogger(AIFFFileParser.class); + private static final String SUPPORTED_FORMATS = "Only 16 and 24 bit PCM or 32-bit float AIF files supported."; static final int AIFF_ID = ('A' << 24) | ('I' << 16) | ('F' << 8) | 'F'; static final int AIFC_ID = ('A' << 24) | ('I' << 16) | ('F' << 8) | 'C'; @@ -75,7 +80,7 @@ public class AIFFFileParser extends AudioFileParser { parser.read(bytes); int exp = ((bytes[0] & 0x3F) << 8) | (bytes[1] & 0xFF); int mant = ((bytes[2] & 0xFF) << 16) | ((bytes[3] & 0xFF) << 8) | (bytes[4] & 0xFF); - // System.out.println( "exp = " + exp + ", mant = " + mant ); + // LOGGER.debug( "exp = " + exp + ", mant = " + mant ); return mant / (double) (1 << (22 - exp)); } @@ -135,7 +140,7 @@ public class AIFFFileParser extends AudioFileParser { void parseSSNDChunk(IFFParser parser, int ckSize) throws IOException { long numRead; - // System.out.println("parseSSNDChunk()"); + // LOGGER.debug("parseSSNDChunk()"); int offset = parser.readIntBig(); parser.readIntBig(); /* blocksize */ parser.skip(offset); @@ -154,14 +159,14 @@ public class AIFFFileParser extends AudioFileParser { void parseMARKChunk(IFFParser parser, int ckSize) throws IOException { long startOffset = parser.getOffset(); int numCuePoints = parser.readShortBig(); - // System.out.println( "parseCueChunk: numCuePoints = " + numCuePoints + // LOGGER.debug( "parseCueChunk: numCuePoints = " + numCuePoints // ); for (int i = 0; i < numCuePoints; i++) { // Some AIF files have a bogus numCuePoints so check to see if we // are at end. long numInMark = parser.getOffset() - startOffset; if (numInMark >= ckSize) { - System.out.println("Reached end of MARK chunk with bogus numCuePoints = " + LOGGER.debug("Reached end of MARK chunk with bogus numCuePoints = " + numCuePoints); break; } @@ -179,14 +184,14 @@ public class AIFFFileParser extends AudioFileParser { cuePoint.name = markerName; if (IFFParser.debug) { - System.out.println("AIFF Marker at " + position + ", " + markerName); + LOGGER.debug("AIFF Marker at " + position + ", " + markerName); } } } /** * Called by parse() method to handle FORM chunks in an AIFF specific manner. - * + * * @param ckID four byte chunk ID such as 'data' * @param ckSize size of chunk in bytes * @exception IOException If parsing fails, or IO error occurs. @@ -199,7 +204,7 @@ public class AIFFFileParser extends AudioFileParser { /** * Called by parse() method to handle chunks in an AIFF specific manner. - * + * * @param ckID four byte chunk ID such as 'data' * @param ckSize size of chunk in bytes * @exception IOException If parsing fails, or IO error occurs. diff --git a/src/com/jsyn/util/soundfile/AudioFileParser.java b/src/main/java/com/jsyn/util/soundfile/AudioFileParser.java index e7bb066..e7bb066 100644 --- a/src/com/jsyn/util/soundfile/AudioFileParser.java +++ b/src/main/java/com/jsyn/util/soundfile/AudioFileParser.java diff --git a/src/com/jsyn/util/soundfile/ChunkHandler.java b/src/main/java/com/jsyn/util/soundfile/ChunkHandler.java index 6dfe26d..6dfe26d 100644 --- a/src/com/jsyn/util/soundfile/ChunkHandler.java +++ b/src/main/java/com/jsyn/util/soundfile/ChunkHandler.java diff --git a/src/com/jsyn/util/soundfile/CustomSampleLoader.java b/src/main/java/com/jsyn/util/soundfile/CustomSampleLoader.java index 14efde9..14efde9 100644 --- a/src/com/jsyn/util/soundfile/CustomSampleLoader.java +++ b/src/main/java/com/jsyn/util/soundfile/CustomSampleLoader.java diff --git a/src/com/jsyn/util/soundfile/IFFParser.java b/src/main/java/com/jsyn/util/soundfile/IFFParser.java index f429657..9bb4ec3 100644 --- a/src/com/jsyn/util/soundfile/IFFParser.java +++ b/src/main/java/com/jsyn/util/soundfile/IFFParser.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,6 +16,9 @@ package com.jsyn.util.soundfile; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.EOFException; import java.io.FilterInputStream; import java.io.IOException; @@ -26,13 +29,16 @@ import java.io.InputStream; * placed in a hierarchical file. It was designed by Jerry Morrison at Electronic Arts for the Amiga * computer and is now used extensively by Apple Computer and other companies. IFF is an open * standard. - * + * * @see RIFFParser * @see AudioSampleAIFF * @author (C) 1997 Phil Burk, SoftSynth.com */ class IFFParser extends FilterInputStream { + + private static final Logger LOGGER = LoggerFactory.getLogger(IFFParser.class); + private long numBytesRead = 0; private long totalSize = 0; private int fileId; @@ -50,7 +56,7 @@ class IFFParser extends FilterInputStream { /** * Size of file based on outermost chunk size plus 8. Can be used to report progress when * loading samples. - * + * * @return Number of bytes in outer chunk plus header. */ public long getFileSize() { @@ -60,7 +66,7 @@ class IFFParser extends FilterInputStream { /** * Since IFF files use chunks with explicit size, it is important to keep track of how many * bytes have been read from the file. Can be used to report progress when loading samples. - * + * * @return Number of bytes read from stream, or skipped. */ public long getOffset() { @@ -95,7 +101,7 @@ class IFFParser extends FilterInputStream { cursor += numRead; numBytesRead += numRead; numLeft -= numRead; - // System.out.println("read " + numRead + ", cursor = " + cursor + + // LOGGER.debug("read " + numRead + ", cursor = " + cursor + // ", len = " + len); } return cursor - off; @@ -192,7 +198,7 @@ class IFFParser extends FilterInputStream { totalSize = numBytes + 8; parseChunk(handler, fileId, numBytes); if (debug) - System.out.println("parse() ------- end"); + LOGGER.debug("parse() ------- end"); } /** @@ -201,14 +207,14 @@ class IFFParser extends FilterInputStream { */ void parseForm(ChunkHandler handler, int ID, int numBytes, int type) throws IOException { if (debug) { - System.out.println("IFF: parseForm >>>>>>>>>>>>>>>>>> BEGIN"); + LOGGER.debug("IFF: parseForm >>>>>>>>>>>>>>>>>> BEGIN"); } while (numBytes > 8) { int ckid = readIntBig(); int size = readChunkSize(); numBytes -= 8; if (debug) { - System.out.println("chunk( " + IDToString(ckid) + ", " + size + " )"); + LOGGER.debug("chunk( " + IDToString(ckid) + ", " + size + " )"); } if (size < 0) { throw new IOException("Bad IFF chunk Size: " + IDToString(ckid) + " = 0x" @@ -219,15 +225,15 @@ class IFFParser extends FilterInputStream { size++; // even-up numBytes -= size; if (debug) { - System.out.println("parseForm: numBytes left in form = " + numBytes); + LOGGER.debug("parseForm: numBytes left in form = " + numBytes); } } if (debug) { - System.out.println("IFF: parseForm <<<<<<<<<<<<<<<<<<<< END"); + LOGGER.debug("IFF: parseForm <<<<<<<<<<<<<<<<<<<< END"); } if (numBytes > 0) { - System.out.println("IFF Parser detected " + numBytes + LOGGER.debug("IFF Parser detected " + numBytes + " bytes of garbage at end of FORM."); skip(numBytes); } @@ -244,7 +250,7 @@ class IFFParser extends FilterInputStream { if (isForm(ckid)) { int type = readIntBig(); if (debug) - System.out.println("parseChunk: form = " + IDToString(ckid) + ", " + numBytes + LOGGER.debug("parseChunk: form = " + IDToString(ckid) + ", " + numBytes + ", " + IDToString(type)); handler.handleForm(this, ckid, numBytes - 4, type); endOffset = getOffset(); @@ -257,8 +263,8 @@ class IFFParser extends FilterInputStream { endOffset = getOffset(); numRead = (int) (endOffset - startOffset); if (debug) { - System.out.println("parseChunk: endOffset = " + endOffset); - System.out.println("parseChunk: numRead = " + numRead); + LOGGER.debug("parseChunk: endOffset = " + endOffset); + LOGGER.debug("parseChunk: numRead = " + numRead); } if ((numBytes & 1) == 1) numBytes++; // even-up @@ -268,7 +274,7 @@ class IFFParser extends FilterInputStream { public void readHead() throws IOException { if (debug) - System.out.println("parse() ------- begin"); + LOGGER.debug("parse() ------- begin"); numBytesRead = 0; fileId = readIntBig(); } diff --git a/src/com/jsyn/util/soundfile/WAVEFileParser.java b/src/main/java/com/jsyn/util/soundfile/WAVEFileParser.java index ec9350c..a083961 100644 --- a/src/com/jsyn/util/soundfile/WAVEFileParser.java +++ b/src/main/java/com/jsyn/util/soundfile/WAVEFileParser.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,8 +22,13 @@ import java.io.IOException; import com.jsyn.data.FloatSample; import com.jsyn.data.SampleMarker; import com.jsyn.util.SampleLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class WAVEFileParser extends AudioFileParser implements ChunkHandler { + + private static final Logger LOGGER = LoggerFactory.getLogger(WAVEFileParser.class); + static final short WAVE_FORMAT_PCM = 1; static final short WAVE_FORMAT_IEEE_FLOAT = 3; static final short WAVE_FORMAT_EXTENSIBLE = (short) 0xFFFE; @@ -90,7 +95,7 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { void parseCueChunk(IFFParser parser, int ckSize) throws IOException { int numCuePoints = parser.readIntLittle(); if (IFFParser.debug) { - System.out.println("WAV: numCuePoints = " + numCuePoints); + LOGGER.debug("WAV: numCuePoints = " + numCuePoints); } if ((ckSize - 4) != (6 * 4 * numCuePoints)) throw new EOFException("Cue chunk too short!"); @@ -101,7 +106,7 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { int sampleOffset = parser.readIntLittle(); // dwPosition if (IFFParser.debug) { - System.out.println("WAV: parseCueChunk: #" + i + ", dwPosition = " + position + LOGGER.debug("WAV: parseCueChunk: #" + i + ", dwPosition = " + position + ", dwName = " + dwName + ", dwSampleOffset = " + sampleOffset); } SampleMarker cuePoint = findOrCreateCuePoint(dwName); @@ -114,7 +119,7 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { int textLength = (ckSize - 4) - 1; // don't read NUL terminator String text = parseString(parser, textLength); if (IFFParser.debug) { - System.out.println("WAV: label id = " + dwName + ", text = " + text); + LOGGER.debug("WAV: label id = " + dwName + ", text = " + text); } SampleMarker cuePoint = findOrCreateCuePoint(dwName); cuePoint.name = text; @@ -129,7 +134,7 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { if (textLength > 0) { String text = parseString(parser, textLength); if (IFFParser.debug) { - System.out.println("WAV: ltxt id = " + dwName + ", dwSampleLength = " + LOGGER.debug("WAV: ltxt id = " + dwName + ", dwSampleLength = " + dwSampleLength + ", text = " + text); } SampleMarker cuePoint = findOrCreateCuePoint(dwName); @@ -146,9 +151,9 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { bitsPerSample = parser.readShortLittle(); if (IFFParser.debug) { - System.out.println("WAV: format = 0x" + Integer.toHexString(format)); - System.out.println("WAV: bitsPerSample = " + bitsPerSample); - System.out.println("WAV: samplesPerFrame = " + samplesPerFrame); + LOGGER.debug("WAV: format = 0x" + Integer.toHexString(format)); + LOGGER.debug("WAV: bitsPerSample = " + bitsPerSample); + LOGGER.debug("WAV: samplesPerFrame = " + samplesPerFrame); } bytesPerFrame = blockAlign; bytesPerSample = bytesPerFrame / samplesPerFrame; @@ -161,14 +166,14 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { byte[] guid = new byte[16]; parser.read(guid); if (IFFParser.debug) { - System.out.println("WAV: extraSize = " + extraSize); - System.out.println("WAV: validBitsPerSample = " + validBitsPerSample); - System.out.println("WAV: channelMask = " + channelMask); + LOGGER.debug("WAV: extraSize = " + extraSize); + LOGGER.debug("WAV: validBitsPerSample = " + validBitsPerSample); + LOGGER.debug("WAV: channelMask = " + channelMask); System.out.print("guid = {"); for (int i = 0; i < guid.length; i++) { System.out.print(guid[i] + ", "); } - System.out.println("}"); + LOGGER.debug("}"); } if (matchBytes(guid, KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) { format = WAVE_FORMAT_IEEE_FLOAT; @@ -204,8 +209,7 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { if (samplesPerFrame == 0) { throw new IOException("WAV file has samplesPerFrame = zero"); } - int nFrames = (samplesPerBlock * byteOffset) / (samplesPerFrame * blockAlign); - return nFrames; + return (samplesPerBlock * byteOffset) / (samplesPerFrame * blockAlign); } private int calculateNumFrames(int numBytes) throws IOException { @@ -289,7 +293,7 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { /** * Called by parse() method to handle chunks in a WAV specific manner. - * + * * @param ckID four byte chunk ID such as 'data' * @param ckSize size of chunk in bytes * @return number of bytes left in chunk diff --git a/src/com/softsynth/math/AudioMath.java b/src/main/java/com/softsynth/math/AudioMath.java index 6d5ab07..06eb45b 100644 --- a/src/com/softsynth/math/AudioMath.java +++ b/src/main/java/com/softsynth/math/AudioMath.java @@ -32,16 +32,14 @@ public class AudioMath { * Convert amplitude to decibels. 1.0 is zero dB. 0.5 is -6.02 dB. */ public static double amplitudeToDecibels(double amplitude) { - double db = Math.log(amplitude) * a2dScalar; - return db; + return Math.log(amplitude) * a2dScalar; } /** * Convert decibels to amplitude. Zero dB is 1.0 and -6.02 dB is 0.5. */ public static double decibelsToAmplitude(double decibels) { - double amp = Math.pow(10.0, decibels / 20.0); - return amp; + return Math.pow(10.0, decibels / 20.0); } /** diff --git a/src/com/softsynth/math/ChebyshevPolynomial.java b/src/main/java/com/softsynth/math/ChebyshevPolynomial.java index bc0e854..bc0e854 100644 --- a/src/com/softsynth/math/ChebyshevPolynomial.java +++ b/src/main/java/com/softsynth/math/ChebyshevPolynomial.java diff --git a/src/com/softsynth/math/FourierMath.java b/src/main/java/com/softsynth/math/FourierMath.java index d133d7f..d133d7f 100644 --- a/src/com/softsynth/math/FourierMath.java +++ b/src/main/java/com/softsynth/math/FourierMath.java diff --git a/src/com/softsynth/math/JustRatio.java b/src/main/java/com/softsynth/math/JustRatio.java index f4070b4..f4070b4 100644 --- a/src/com/softsynth/math/JustRatio.java +++ b/src/main/java/com/softsynth/math/JustRatio.java diff --git a/src/com/softsynth/math/Polynomial.java b/src/main/java/com/softsynth/math/Polynomial.java index 5f29f38..6c6f96a 100644 --- a/src/com/softsynth/math/Polynomial.java +++ b/src/main/java/com/softsynth/math/Polynomial.java @@ -16,6 +16,9 @@ package com.softsynth.math; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Vector; /** @@ -29,9 +32,12 @@ import java.util.Vector; public class Polynomial { + private static final Logger LOGGER = LoggerFactory.getLogger(Polynomial.class); + private final Vector terms; - class DoubleHolder { + // TODO: Does this need to exist? + static class DoubleHolder { double value; public DoubleHolder(double val) { @@ -217,36 +223,36 @@ public class Polynomial { return s; } - public static void main(String args[]) { + public static void main(String[] args) { Polynomial p1 = new Polynomial(); - System.out.println("p1=" + p1); + LOGGER.debug("p1=" + p1); Polynomial p2 = new Polynomial(3); - System.out.println("p2=" + p2); + LOGGER.debug("p2=" + p2); Polynomial p3 = new Polynomial(2, 3); - System.out.println("p3=" + p3); + LOGGER.debug("p3=" + p3); Polynomial p4 = new Polynomial(1, 2, 3); - System.out.println("p4=" + p4); - System.out.println("p4*5=" + Polynomial.mult(5.0, p4)); + LOGGER.debug("p4=" + p4); + LOGGER.debug("p4*5=" + Polynomial.mult(5.0, p4)); - System.out.println(p4.evaluate(10)); + LOGGER.debug("{}", p4.evaluate(10)); - System.out.println(Polynomial.plus(p4, p1)); - System.out.println(Polynomial.minus(p4, p3)); + LOGGER.debug("{}", Polynomial.plus(p4, p1)); + LOGGER.debug("{}", Polynomial.minus(p4, p3)); p4.setTerm(12.2, 5); - System.out.println(p4); + LOGGER.debug("{}", p4); p4.addTerm(0.8, 5); - System.out.println(p4); + LOGGER.debug("{}", p4); p4.addTerm(0.8, 7); - System.out.println(p4); - System.out.println(Polynomial.mult(p3, p2)); - System.out.println(Polynomial.mult(p3, p3)); - System.out.println(Polynomial.mult(p2, p2)); + LOGGER.debug("{}", p4); + LOGGER.debug("{}", Polynomial.mult(p3, p2)); + LOGGER.debug("{}", Polynomial.mult(p3, p3)); + LOGGER.debug("{}", Polynomial.mult(p2, p2)); Polynomial t2 = new Polynomial(2, 0, -1); // 2x^2-1, Chebyshev Polynomial of order 2 Polynomial t3 = new Polynomial(4, 0, -3, 0); // 4x^3-3x, Chebyshev Polynomial of order 3 // Calculate Chebyshev Polynomial of order 4 from relation Tk+1(x) = 2xTk(x) - Tk-1(x) Polynomial t4 = Polynomial.minus(Polynomial.mult(t3, (new Polynomial(2, 0))), t2); - System.out.println(t2 + "\n" + t3 + "\n" + t4); + LOGGER.debug(t2 + "\n" + t3 + "\n" + t4); // com.softsynth.jmsl.util } diff --git a/src/com/softsynth/math/PolynomialTableData.java b/src/main/java/com/softsynth/math/PolynomialTableData.java index 676c77c..8110151 100644 --- a/src/com/softsynth/math/PolynomialTableData.java +++ b/src/main/java/com/softsynth/math/PolynomialTableData.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +20,7 @@ package com.softsynth.math; * PolynomialTableData<br> * Provides an array of double[] containing data generated by a polynomial.<br> * This is typically used with ChebyshevPolynomial. Input to Polynomial is -1..1, output is -1..1. - * + * * @author Nick Didkovsky (C) 1997 Phil Burk and Nick Didkovsky * @see ChebyshevPolynomial * @see Polynomial @@ -52,12 +52,12 @@ public class PolynomialTableData { for (int i = 0; i < data.length; i++) { x = i * xInterval - 1.0; data[i] = polynomial.evaluate(x); - // System.out.println("x = " + x + ", p(x) = " + data[i] ); + // LOGGER.debug("x = " + x + ", p(x) = " + data[i] ); } } - public static void main(String args[]) { + public static void main(String[] args) { PolynomialTableData chebData = new PolynomialTableData(ChebyshevPolynomial.T(2), 8); } diff --git a/src/com/softsynth/math/PrimeFactors.java b/src/main/java/com/softsynth/math/PrimeFactors.java index 06c0d55..06c0d55 100644 --- a/src/com/softsynth/math/PrimeFactors.java +++ b/src/main/java/com/softsynth/math/PrimeFactors.java diff --git a/src/com/softsynth/shared/time/ScheduledCommand.java b/src/main/java/com/softsynth/shared/time/ScheduledCommand.java index 5b600a7..5b600a7 100644 --- a/src/com/softsynth/shared/time/ScheduledCommand.java +++ b/src/main/java/com/softsynth/shared/time/ScheduledCommand.java diff --git a/src/com/softsynth/shared/time/ScheduledQueue.java b/src/main/java/com/softsynth/shared/time/ScheduledQueue.java index 367e4f8..367e4f8 100644 --- a/src/com/softsynth/shared/time/ScheduledQueue.java +++ b/src/main/java/com/softsynth/shared/time/ScheduledQueue.java diff --git a/src/com/softsynth/shared/time/TimeStamp.java b/src/main/java/com/softsynth/shared/time/TimeStamp.java index 6d243ed..6d243ed 100644 --- a/src/com/softsynth/shared/time/TimeStamp.java +++ b/src/main/java/com/softsynth/shared/time/TimeStamp.java diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml new file mode 100644 index 0000000..cc107b1 --- /dev/null +++ b/src/main/resources/log4j.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" > +<log4j:configuration debug="false"> + <appender name="default.console" class="org.apache.log4j.ConsoleAppender"> + <param name="target" value="System.out"/> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="[%d{HH:mm:ss}] [%t/%p]: %m%n"/> + </layout> + </appender> + + <root> + <priority value="INFO" /> + <appender-ref ref="default.console"/> + </root> +</log4j:configuration> diff --git a/tests/com/jsyn/benchmarks/BenchJSyn.java b/src/test/java/com/jsyn/benchmarks/BenchJSyn.java index 5b8d128..017dc99 100644 --- a/tests/com/jsyn/benchmarks/BenchJSyn.java +++ b/src/test/java/com/jsyn/benchmarks/BenchJSyn.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,7 +14,7 @@ * limitations under the License. */ /** - * + * */ package com.jsyn.benchmarks; @@ -23,35 +23,35 @@ import com.jsyn.JSyn; import com.jsyn.Synthesizer; import com.jsyn.unitgen.PassThrough; import com.jsyn.unitgen.PitchDetector; -import com.jsyn.unitgen.SawtoothOscillator; -import com.jsyn.unitgen.SawtoothOscillatorBL; -import com.jsyn.unitgen.SawtoothOscillatorDPW; import com.jsyn.unitgen.SineOscillator; import com.jsyn.unitgen.SquareOscillator; import com.jsyn.unitgen.SquareOscillatorBL; import com.jsyn.unitgen.UnitOscillator; import com.softsynth.math.FourierMath; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Phil Burk (C) 2013 Mobileer Inc */ public class BenchJSyn { + + private static final Logger LOGGER = LoggerFactory.getLogger(BenchJSyn.class); + private Synthesizer synth; private long startTime; private long endTime; private PassThrough pass; + @Test public void run() { try { // Run multiple times to see if HotSpot compiler or cache makes a difference. for (int i = 0; i < 4; i++) { benchmark(); } - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InterruptedException e) { + } catch (InstantiationException | IllegalAccessException | InterruptedException e) { e.printStackTrace(); } } @@ -86,7 +86,7 @@ public class BenchJSyn { double amplitude = 1.0; addSineWave(size, bin, ar, amplitude); - System.out.println("Bench double FFT"); + LOGGER.debug("Bench double FFT"); startTiming(); for (int i = 0; i < count; i++) { FourierMath.transform(1, size, ar, ai); @@ -112,7 +112,7 @@ public class BenchJSyn { float amplitude = 1.0f; addSineWave(size, bin, ar, amplitude); - System.out.println("Bench float FFT"); + LOGGER.debug("Bench float FFT"); startTiming(); for (int i = 0; i < count; i++) { FourierMath.transform(1, size, ar, ai); @@ -132,7 +132,7 @@ public class BenchJSyn { double phaseIncrement = 2.0 * Math.PI * bin / size; for (int i = 0; i < size; i++) { ar[i] += Math.sin(phase) * amplitude; - // System.out.println( i + " = " + ar[i] ); + // LOGGER.debug( i + " = " + ar[i] ); phase += phaseIncrement; } } @@ -142,7 +142,7 @@ public class BenchJSyn { float phaseIncrement = (float) (2.0 * Math.PI * bin / size); for (int i = 0; i < size; i++) { ar[i] += (float) Math.sin(phase) * amplitude; - // System.out.println( i + " = " + ar[i] ); + // LOGGER.debug( i + " = " + ar[i] ); phase += phaseIncrement; } } @@ -198,7 +198,7 @@ public class BenchJSyn { double measuredPeriod = detector.period.getValue(); double confidence = detector.confidence.getValue(); - System.out.println("period = " + period + ", measured = " + measuredPeriod + LOGGER.debug("period = " + period + ", measured = " + measuredPeriod + ", confidence = " + confidence); if (confidence > 0.1) { assert (Math.abs(measuredPeriod - period) < 0.1); @@ -218,11 +218,11 @@ public class BenchJSyn { startTime = System.nanoTime(); } - /** - * @param args - */ - public static void main(String[] args) { - new BenchJSyn().run(); - } +// /** +// * @param args +// */ +// public static void main(String[] args) { +// new BenchJSyn().run(); +// } } diff --git a/tests/com/jsyn/data/TestShortSample.java b/src/test/java/com/jsyn/data/TestShortSample.java index 3837c19..6132e4e 100644 --- a/tests/com/jsyn/data/TestShortSample.java +++ b/src/test/java/com/jsyn/data/TestShortSample.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,37 +16,31 @@ package com.jsyn.data; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Phil Burk, (C) 2009 Mobileer Inc */ -public class TestShortSample extends TestCase { - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } +public class TestShortSample { + @Test public void testBytes() { byte[] bar = { 18, -3 }; short s = (short) ((bar[0] << 8) | (bar[1] & 0xFF)); - assertEquals("A", 0x12FD, s); + assertEquals(0x12FD, s, "A"); } + @Test public void testReadWrite() { short[] data = { 123, 456, -789, 111, 20000, -32768, 32767, 0, 9876 }; ShortSample sample = new ShortSample(data.length, 1); - assertEquals("Sample numFrames", data.length, sample.getNumFrames()); + assertEquals(data.length, sample.getNumFrames(), "Sample numFrames"); // Write and read entire sample. sample.write(data); @@ -54,7 +48,7 @@ public class TestShortSample extends TestCase { sample.read(buffer); for (int i = 0; i < data.length; i++) { - assertEquals("read = write", data[i], buffer[i]); + assertEquals(data[i], buffer[i], "read = write"); } // Write and read part of an array. @@ -67,9 +61,9 @@ public class TestShortSample extends TestCase { for (int i = 0; i < data.length; i++) { if ((i >= 2) && (i <= 4)) { - assertEquals("partial", partial[i - 1], buffer[i]); + assertEquals(partial[i - 1], buffer[i], "partial"); } else { - assertEquals("read = write", data[i], buffer[i]); + assertEquals(data[i], buffer[i], "read = write"); } } diff --git a/tests/com/jsyn/engine/TestAudioOutput.java b/src/test/java/com/jsyn/engine/TestAudioOutput.java index a95d426..39e8211 100644 --- a/tests/com/jsyn/engine/TestAudioOutput.java +++ b/src/test/java/com/jsyn/engine/TestAudioOutput.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,31 +18,23 @@ package com.jsyn.engine; import java.io.IOException; -import junit.framework.TestCase; - import com.jsyn.devices.AudioDeviceManager; import com.jsyn.devices.AudioDeviceOutputStream; import com.jsyn.devices.javasound.JavaSoundAudioDevice; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Phil Burk, (C) 2009 Mobileer Inc */ -public class TestAudioOutput extends TestCase { - - SynthesisEngine synthesisEngine; +public class TestAudioOutput { - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } + private static final Logger LOGGER = LoggerFactory.getLogger(TestAudioOutput.class); + @Test public void testMonoSine() throws IOException { - System.out.println("Test mono output."); + LOGGER.debug("Test mono output."); final int FRAMES_PER_BUFFER = 128; final int SAMPLES_PER_FRAME = 1; double[] buffer = new double[FRAMES_PER_BUFFER * SAMPLES_PER_FRAME]; @@ -61,8 +53,9 @@ public class TestAudioOutput extends TestCase { } + @Test public void testStereoSine() throws IOException { - System.out.println("Test stereo output."); + LOGGER.debug("Test stereo output."); final int FRAMES_PER_BUFFER = 128; final int SAMPLES_PER_FRAME = 2; double[] buffer = new double[FRAMES_PER_BUFFER * SAMPLES_PER_FRAME]; @@ -80,7 +73,6 @@ public class TestAudioOutput extends TestCase { audioOutput.write(buffer); } audioOutput.stop(); - } } diff --git a/tests/com/jsyn/engine/TestDevices.java b/src/test/java/com/jsyn/engine/TestDevices.java index 56f2c1f..307880e 100644 --- a/tests/com/jsyn/engine/TestDevices.java +++ b/src/test/java/com/jsyn/engine/TestDevices.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,17 +16,23 @@ package com.jsyn.engine; -import junit.framework.TestCase; - import com.jsyn.JSyn; import com.jsyn.Synthesizer; import com.jsyn.devices.AudioDeviceFactory; import com.jsyn.devices.AudioDeviceManager; import com.jsyn.unitgen.LineIn; import com.jsyn.unitgen.LineOut; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class TestDevices { + + private static final Logger LOGGER = LoggerFactory.getLogger(TestDevices.class); -public class TestDevices extends TestCase { - // Test audio input and output simultaneously. + @Test public void testPassThrough() { Synthesizer synth; LineIn lineIn; @@ -49,7 +55,7 @@ public class TestDevices extends TestCase { // We only need to start the LineOut. It will pull data from the LineIn. lineOut.start(); - System.out.println("Audio passthrough started."); + LOGGER.debug("Audio passthrough started."); // Sleep a while. double sleepTime = 2.0; try { @@ -60,10 +66,10 @@ public class TestDevices extends TestCase { e.printStackTrace(); } double synthTime = synth.getCurrentTime(); - assertEquals("Time has advanced. " + synthTime, sleepTime, synthTime, 0.2); + assertEquals(synthTime, 0.2, "Time has advanced. " + synthTime); // Stop everything. synth.stop(); - System.out.println("All done."); + LOGGER.debug("All done."); } } diff --git a/tests/com/jsyn/engine/TestEngine.java b/src/test/java/com/jsyn/engine/TestEngine.java index 9572f3d..0ba70d6 100644 --- a/tests/com/jsyn/engine/TestEngine.java +++ b/src/test/java/com/jsyn/engine/TestEngine.java @@ -16,30 +16,37 @@ package com.jsyn.engine; -import junit.framework.TestCase; - import com.jsyn.unitgen.Add; import com.jsyn.unitgen.LineOut; import com.jsyn.unitgen.PitchDetector; import com.jsyn.unitgen.SineOscillator; import com.jsyn.unitgen.ZeroCrossingCounter; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class TestEngine extends TestCase { +public class TestEngine { + private static final Logger LOGGER = LoggerFactory.getLogger(TestEngine.class); + + @Test public void testInitialization() { final int DEFAULT_FRAME_RATE = 44100; SynthesisEngine synthesisEngine = new SynthesisEngine(); - assertEquals("frameCount zero before starting", 0, synthesisEngine.getFrameCount()); - assertEquals("default frameRate", DEFAULT_FRAME_RATE, synthesisEngine.getFrameRate()); - assertEquals("default pullData", true, synthesisEngine.isPullDataEnabled()); + assertEquals(0, synthesisEngine.getFrameCount(), "frameCount zero before starting"); + assertEquals(DEFAULT_FRAME_RATE, synthesisEngine.getFrameRate(), "default frameRate"); + assertTrue(synthesisEngine.isPullDataEnabled(), "default pullData"); } public void checkPullData(boolean pullData) { SynthesisEngine synthesisEngine = new SynthesisEngine(); - assertEquals("default realTime", true, synthesisEngine.isRealTime()); + assertTrue(synthesisEngine.isRealTime(), "default realTime"); synthesisEngine.setRealTime(false); - assertEquals("default pullData", true, synthesisEngine.isPullDataEnabled()); + assertTrue(synthesisEngine.isPullDataEnabled(), "default pullData"); synthesisEngine.setPullDataEnabled(pullData); SineOscillator sineOscillator = new SineOscillator(); @@ -49,7 +56,7 @@ public class TestEngine extends TestCase { synthesisEngine.add(lineOut); sineOscillator.output.connect(0, lineOut.input, 0); - assertEquals("initial sine value", 0.0, sineOscillator.output.getValue()); + assertEquals(0.0, sineOscillator.output.getValue(), "initial sine value"); synthesisEngine.start(); if (!pullData) { @@ -61,17 +68,20 @@ public class TestEngine extends TestCase { synthesisEngine.generateNextBuffer(); double value = sineOscillator.output.getValue(); - assertTrue("sine value after generation = " + value, (value > 0.0)); + assertTrue(value > 0.0, "sine value after generation = " + value); } + @Test public void testPullDataFalse() { checkPullData(false); } + @Test public void testPullDataTrue() { checkPullData(true); } + @Test public void testMixedAdding() { boolean gotCaught = false; SynthesisEngine synthesisEngine1 = new SynthesisEngine(); @@ -91,12 +101,13 @@ public class TestEngine extends TestCase { sineOscillator.output.connect(0, lineOut.input, 0); } catch (RuntimeException e) { gotCaught = true; - assertTrue("informative MPE message", e.getMessage().contains("different synths")); + assertTrue(e.getMessage().contains("different synths"), "informative MPE message"); } - assertTrue("caught NPE caused by forgetting synth.add", gotCaught); + assertTrue(gotCaught, "caught NPE caused by forgetting synth.add"); } + @Test public void testNotAdding() { SynthesisEngine synthesisEngine = new SynthesisEngine(); synthesisEngine.setRealTime(false); @@ -109,7 +120,7 @@ public class TestEngine extends TestCase { sineOscillator.output.connect(0, lineOut.input, 0); synthesisEngine.add(lineOut); - assertEquals("initial sine value", 0.0, sineOscillator.output.getValue()); + assertEquals(0.0, sineOscillator.output.getValue(), "initial sine value"); synthesisEngine.start(); // We always have to start the LineOut. @@ -120,12 +131,13 @@ public class TestEngine extends TestCase { synthesisEngine.generateNextBuffer(); } catch (NullPointerException e) { gotCaught = true; - assertTrue("informative MPE message", e.getMessage().contains("forgot to add")); + assertTrue(e.getMessage().contains("forgot to add"), "informative MPE message"); } - assertTrue("caught NPE caused by forgetting synth.add", gotCaught); + assertTrue(gotCaught, "caught NPE caused by forgetting synth.add"); } + @Test public void testMultipleStarts() throws InterruptedException { SynthesisEngine synth = new SynthesisEngine(); @@ -142,7 +154,7 @@ public class TestEngine extends TestCase { osc.output.connect(pitchDetector.input); counter.output.connect(0, lineOut.input, 0); - assertEquals("initial count", 0, counter.getCount()); + assertEquals(0, counter.getCount(), "initial count"); int[] rates = { 32000, 48000, 44100, 22050 @@ -163,22 +175,22 @@ public class TestEngine extends TestCase { double confidenceMeasured = pitchDetector.confidence.get(); double oscFreq = osc.frequency.get(); String msg = "freq at " + rate + " Hz"; - System.out.println(msg); - assertEquals(msg, oscFreq, frequencyMeasured, oscFreq * 0.1); - assertEquals("pitch confidence", 0.9, confidenceMeasured, 0.1); + LOGGER.debug(msg); + assertEquals(oscFreq, frequencyMeasured, oscFreq * 0.1, msg); + assertEquals(0.9, confidenceMeasured, 0.1, "pitch confidence"); double expectedCount = interval * oscFreq; double framesMeasured = counter.getCount() - previousFrameCount; msg = "count at " + rate + " Hz"; - System.out.println(msg); - assertEquals(msg, expectedCount, framesMeasured, expectedCount * 0.1); + LOGGER.debug(msg); + assertEquals(expectedCount, framesMeasured, expectedCount * 0.1, msg); synth.stop(); } } - + @Test public void testScheduler() throws InterruptedException { SynthesisEngine synth = new SynthesisEngine(); synth.setRealTime(false); @@ -189,24 +201,24 @@ public class TestEngine extends TestCase { adder.inputA.set(4.0); adder.inputB.set(10.0); synth.sleepFor(0.1); - assertEquals("simple add", 14.0, adder.output.get(), 0.01); + assertEquals(14.0, adder.output.get(), 0.01, "simple add"); // Schedule a set() in the near future. double time = synth.getCurrentTime(); adder.inputA.set(7.0, time + 1.0); synth.sleepFor(0.5); - assertEquals("before scheduled set", 14.0, adder.output.get(), 0.01); + assertEquals(14.0, adder.output.get(), 0.01, "before scheduled set"); synth.sleepFor(1.0); - assertEquals("after scheduled set", 17.0, adder.output.get(), 0.01); + assertEquals(17.0, adder.output.get(), 0.01, "after scheduled set"); // Schedule a set() in the near future then cancel it. time = synth.getCurrentTime(); adder.inputA.set(5.0, time + 1.0); synth.sleepFor(0.5); - assertEquals("before scheduled set", 17.0, adder.output.get(), 0.01); + assertEquals(17.0, adder.output.get(), 0.01, "before scheduled set"); synth.clearCommandQueue(); synth.sleepFor(1.0); - assertEquals("after canceled set", 17.0, adder.output.get(), 0.01); + assertEquals(17.0, adder.output.get(), 0.01, "after canceled set"); synth.stop(); } diff --git a/tests/com/jsyn/engine/TestFifo.java b/src/test/java/com/jsyn/engine/TestFifo.java index 03333bf..d057e19 100644 --- a/tests/com/jsyn/engine/TestFifo.java +++ b/src/test/java/com/jsyn/engine/TestFifo.java @@ -16,34 +16,38 @@ package com.jsyn.engine; -import junit.framework.TestCase; - import com.jsyn.io.AudioFifo; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; -public class TestFifo extends TestCase { +public class TestFifo { + @Test public void testBasic() { Thread watchdog = startWatchdog(600); AudioFifo fifo = new AudioFifo(); fifo.setReadWaitEnabled(false); fifo.allocate(8); - assertEquals("start empty", 0, fifo.available()); + assertEquals(0, fifo.available(), "start empty"); - assertEquals("read back Nan when emopty", Double.NaN, fifo.read()); + assertEquals(Double.NaN, fifo.read(), "read back Nan when emopty"); fifo.write(1.0); - assertEquals("added one value", 1, fifo.available()); - assertEquals("read back same value", 1.0, fifo.read()); - assertEquals("back to empty", 0, fifo.available()); + assertEquals(1, fifo.available(), "added one value"); + assertEquals(1.0, fifo.read(), "read back same value"); + assertEquals(0, fifo.available(), "back to empty"); for (int i = 0; i < fifo.size(); i++) { - assertEquals("adding data", i, fifo.available()); + assertEquals(i, fifo.available(), "adding data"); fifo.write(100.0 + i); } for (int i = 0; i < fifo.size(); i++) { - assertEquals("removing data", fifo.size() - i, fifo.available()); - assertEquals("reading back data", 100.0 + i, fifo.read()); + assertEquals(fifo.size() - i, fifo.available(), "removing data"); + assertEquals(100.0 + i, fifo.read(), "reading back data"); } watchdog.interrupt(); } @@ -51,6 +55,7 @@ public class TestFifo extends TestCase { /** * Wrap around several times to test masking. */ + @Test public void testWrapping() { final int chunk = 5; @@ -65,28 +70,30 @@ public class TestFifo extends TestCase { private double checkFifoChunk(AudioFifo fifo, double value, int chunk) { for (int i = 0; i < chunk; i++) { - assertEquals("adding data", i, fifo.available()); + assertEquals(i, fifo.available(), "adding data"); fifo.write(value + i); } for (int i = 0; i < chunk; i++) { - assertEquals("removing data", chunk - i, fifo.available()); - assertEquals("reading back data", value + i, fifo.read()); + assertEquals(chunk - i, fifo.available(), "removing data"); + assertEquals(value + i, fifo.read(), "reading back data"); } return value + chunk; } + @Test public void testBadSize() { - boolean caught = false; try { AudioFifo fifo = new AudioFifo(); fifo.allocate(20); // not power of 2 - assertTrue("should not get here", false); - } catch (IllegalArgumentException e) { - caught = true; + fail("should not get here"); + } catch (IllegalArgumentException ignored) { + return; } - assertTrue("should have caught size exception", caught); + + fail("should have caught size exception"); } + @Test public void testSingleReadWait() { final int chunk = 5; final AudioFifo fifo = new AudioFifo(); @@ -97,42 +104,37 @@ public class TestFifo extends TestCase { final double value = 50.0; // Schedule a delayed write in another thread. - new Thread() { - @Override - public void run() { - try { - sleep(200); - for (int i = 0; i < chunk; i++) { - fifo.write(value + i); - } - } catch (InterruptedException e) { - e.printStackTrace(); + new Thread(() -> { + try { + Thread.sleep(200); + for (int i = 0; i < chunk; i++) { + fifo.write(value + i); } + } catch (InterruptedException e) { + e.printStackTrace(); } - }.start(); + }).start(); Thread watchdog = startWatchdog(500); for (int i = 0; i < chunk; i++) { - assertEquals("reading back data", value + i, fifo.read()); + assertEquals(value + i, fifo.read(), "reading back data"); } watchdog.interrupt(); } private Thread startWatchdog(final int msec) { - Thread watchdog = new Thread() { - @Override - public void run() { - try { - sleep(msec); - assertTrue("test must still be waiting", false); - } catch (InterruptedException e) { - } + Thread watchdog = new Thread(() -> { + try { + Thread.sleep(msec); + fail("test must still be waiting"); + } catch (InterruptedException ignored) { } - }; + }); watchdog.start(); return watchdog; } + @Test public void testSingleWriteWait() { final int chunk = 13; final AudioFifo fifo = new AudioFifo(); @@ -143,22 +145,19 @@ public class TestFifo extends TestCase { final double value = 50.0; // Schedule a delayed read in another thread. - Thread readThread = new Thread() { - @Override - public void run() { - try { - sleep(200); - for (int i = 0; i < chunk; i++) { - // System.out.println( "testSingleWriteWait: try to read" ); - double got = fifo.read(); - assertEquals("adding data", value + i, got); - // System.out.println( "testSingleWriteWait: read " + got ); - } - } catch (InterruptedException e) { - e.printStackTrace(); + Thread readThread = new Thread(() -> { + try { + Thread.sleep(200); + for (int i = 0; i < chunk; i++) { + // LOGGER.debug( "testSingleWriteWait: try to read" ); + double got = fifo.read(); + assertEquals(value + i, got, "adding data"); + // LOGGER.debug( "testSingleWriteWait: read " + got ); } + } catch (InterruptedException e) { + e.printStackTrace(); } - }; + }); readThread.start(); Thread watchdog = startWatchdog(500); @@ -173,9 +172,10 @@ public class TestFifo extends TestCase { } catch (InterruptedException e) { e.printStackTrace(); } - assertEquals("readThread should be done.", false, readThread.isAlive()); + assertFalse(readThread.isAlive(), "readThread should be done."); } + @Test public void testBlockReadWait() { final int chunk = 50; final AudioFifo fifo = new AudioFifo(); @@ -187,36 +187,34 @@ public class TestFifo extends TestCase { double[] readBuffer = new double[chunk]; // Schedule delayed writes in another thread. - new Thread() { - @Override - public void run() { - int numWritten = 0; - double[] writeBuffer = new double[4]; - try { - while (numWritten < chunk) { - sleep(30); - for (int i = 0; i < writeBuffer.length; i++) { - writeBuffer[i] = value + numWritten; - numWritten += 1; - } - - fifo.write(writeBuffer); + new Thread(() -> { + int numWritten = 0; + double[] writeBuffer = new double[4]; + try { + while (numWritten < chunk) { + Thread.sleep(30); + for (int i = 0; i < writeBuffer.length; i++) { + writeBuffer[i] = value + numWritten; + numWritten += 1; } - } catch (InterruptedException e) { - e.printStackTrace(); + + fifo.write(writeBuffer); } + } catch (InterruptedException e) { + e.printStackTrace(); } - }.start(); + }).start(); Thread watchdog = startWatchdog(600); fifo.read(readBuffer); for (int i = 0; i < chunk; i++) { - assertEquals("reading back data", value + i, readBuffer[i]); + assertEquals(value + i, readBuffer[i], "reading back data"); } watchdog.interrupt(); } + @Test public void testBlockReadAndWriteWaitStress() { final int chunk = 10000000; // 10 Megabytes final AudioFifo fifo = new AudioFifo(); @@ -227,23 +225,20 @@ public class TestFifo extends TestCase { final double value = 50.0; // Schedule a delayed write in another thread. - new Thread() { - @Override - public void run() { - try { - sleep(200); - for (int i = 0; i < chunk; i++) { - fifo.write(value + i); - } - } catch (InterruptedException e) { - e.printStackTrace(); + new Thread(() -> { + try { + Thread.sleep(200); + for (int i = 0; i < chunk; i++) { + fifo.write(value + i); } + } catch (InterruptedException e) { + e.printStackTrace(); } - }.start(); + }).start(); Thread watchdog = startWatchdog(10000); for (int i = 0; i < chunk; i++) { - assertEquals("reading back data", value + i, fifo.read()); + assertEquals(value + i, fifo.read(), "reading back data"); } watchdog.interrupt(); } diff --git a/tests/com/jsyn/engine/TestWaveFileReadWrite.java b/src/test/java/com/jsyn/engine/TestWaveFileReadWrite.java index ee406de..b5051e6 100644 --- a/tests/com/jsyn/engine/TestWaveFileReadWrite.java +++ b/src/test/java/com/jsyn/engine/TestWaveFileReadWrite.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,29 +19,32 @@ package com.jsyn.engine; import java.io.File; import java.io.IOException; -import javax.sound.sampled.UnsupportedAudioFileException; - -import junit.framework.TestCase; - import com.jsyn.data.FloatSample; import com.jsyn.util.SampleLoader; import com.jsyn.util.WaveFileWriter; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; -public class TestWaveFileReadWrite extends TestCase { +public class TestWaveFileReadWrite { - public void checkWriteReadWave(int numChannels, float[] data) throws IOException, - UnsupportedAudioFileException { + private static final Logger LOGGER = LoggerFactory.getLogger(TestWaveFileReadWrite.class); + + public void checkWriteReadWave(int numChannels, float[] data) throws IOException { File temp = File.createTempFile("test_wave", ".wav"); temp.deleteOnExit(); - System.out.println("Creating wave file " + temp); + LOGGER.debug("Creating wave file " + temp); WaveFileWriter writer = new WaveFileWriter(temp); writer.setFrameRate(44100); writer.setSamplesPerFrame(numChannels); writer.setBitsPerSample(16); - for (int i = 0; i < data.length; i++) { - writer.write(data[i]); + for (var datum : data) { + writer.write(datum); } writer.close(); @@ -49,8 +52,8 @@ public class TestWaveFileReadWrite extends TestCase { // writer.write( 0.7 ); FloatSample sample = SampleLoader.loadFloatSample(temp); - assertEquals("stereo", numChannels, sample.getChannelsPerFrame()); - assertEquals("frame rate", 44100.0, sample.getFrameRate()); + assertEquals(numChannels, sample.getChannelsPerFrame(), "stereo"); + assertEquals(44100.0, sample.getFrameRate(), "frame rate"); for (int i = 0; i < data.length; i++) { float v = data[i]; @@ -58,12 +61,13 @@ public class TestWaveFileReadWrite extends TestCase { v = 1.0f; else if (v < -1.0) v = -1.0f; - assertEquals("sample data", v, sample.readDouble(i), 0.0001); + assertEquals(v, sample.readDouble(i), 0.0001, "sample data"); } } - public void testRamp() throws IOException, UnsupportedAudioFileException { + @Test + public void testRamp() throws IOException { float[] data = new float[200]; for (int i = 0; i < data.length; i++) { data[i] = i / 1000.0f; @@ -72,7 +76,8 @@ public class TestWaveFileReadWrite extends TestCase { checkWriteReadWave(2, data); } - public void testClippedSine() throws IOException, UnsupportedAudioFileException { + @Test + public void testClippedSine() throws IOException { float[] data = new float[200]; for (int i = 0; i < data.length; i++) { double phase = i * Math.PI * 2.0 / 100; @@ -82,26 +87,28 @@ public class TestWaveFileReadWrite extends TestCase { checkWriteReadWave(2, data); } + @Test public void testArguments() throws IOException { File temp = File.createTempFile("test_wave", ".wav"); temp.deleteOnExit(); - System.out.println("Creating wave file " + temp); + LOGGER.debug("Creating wave file " + temp); WaveFileWriter writer = new WaveFileWriter(temp); writer.setBitsPerSample(16); - assertEquals("bitsPerSample", 16, writer.getBitsPerSample()); + assertEquals(16, writer.getBitsPerSample(), "bitsPerSample"); writer.setBitsPerSample(24); - assertEquals("bitsPerSample", 24, writer.getBitsPerSample()); - boolean caughtIt = false; + assertEquals(24, writer.getBitsPerSample(), "bitsPerSample"); try { writer.setBitsPerSample(17); - assertTrue("tried setting illegal value", false); + fail("tried setting illegal value"); } catch (IllegalArgumentException e) { // e.printStackTrace(); - caughtIt = true; + return; + } finally { + writer.close(); } - assertTrue("17 generated exception", caughtIt); - writer.close(); + + fail("17 generated exception"); } } diff --git a/tests/com/jsyn/midi/TestMidiLoop.java b/src/test/java/com/jsyn/midi/TestMidiLoop.java index 5837696..fa7ba2c 100644 --- a/tests/com/jsyn/midi/TestMidiLoop.java +++ b/src/test/java/com/jsyn/midi/TestMidiLoop.java @@ -16,21 +16,15 @@ package com.jsyn.midi; -import java.io.IOException; - import javax.sound.midi.MidiDevice; import javax.sound.midi.MidiMessage; import javax.sound.midi.MidiUnavailableException; import javax.sound.midi.Receiver; -import com.jsyn.JSyn; -import com.jsyn.Synthesizer; import com.jsyn.devices.javasound.MidiDeviceTools; -import com.jsyn.instruments.DualOscillatorSynthVoice; -import com.jsyn.midi.MidiSynthesizer; -import com.jsyn.unitgen.LineOut; -import com.jsyn.util.MultiChannelSynthesizer; -import com.jsyn.util.VoiceDescription; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Connect a USB MIDI Keyboard to the internal MIDI Synthesizer using JavaSound. @@ -39,26 +33,21 @@ import com.jsyn.util.VoiceDescription; */ public class TestMidiLoop { - public static void main(String[] args) { - TestMidiLoop app = new TestMidiLoop(); - int result = 0; + private static final Logger LOGGER = LoggerFactory.getLogger(TestMidiLoop.class); + + @Test + private void midiLoop() { try { - for (int i = 0; i < 3 && result == 0; i++) { - result = app.test(); + for (int result = 0, i = 0; i < 3 && result == 0; i++) { + result = test(); } - } catch (MidiUnavailableException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { + } catch (MidiUnavailableException | InterruptedException e) { e.printStackTrace(); } - System.out.print("Test finished."); - System.exit((result == 0) ? 0 : 1); } // Write a Receiver to get the messages from a Transmitter. - class CustomReceiver implements Receiver { + static class CustomReceiver implements Receiver { @Override public void close() { System.out.print("Receiver.close() was called."); @@ -67,11 +56,11 @@ public class TestMidiLoop { @Override public void send(MidiMessage message, long timeStamp) { byte[] bytes = message.getMessage(); - System.out.println("Got " + bytes.length + " bytes."); + LOGGER.debug("Got " + bytes.length + " bytes."); } } - public int test() throws MidiUnavailableException, IOException, InterruptedException { + public int test() throws MidiUnavailableException, InterruptedException { int result = -1; MidiDevice keyboard = MidiDeviceTools.findKeyboard(); @@ -83,13 +72,13 @@ public class TestMidiLoop { // Put the receiver in the transmitter. // This gives fairly low latency playing. keyboard.getTransmitter().setReceiver(receiver); - System.out.println("Play MIDI keyboard: " + keyboard.getDeviceInfo().getDescription()); + LOGGER.debug("Play MIDI keyboard: " + keyboard.getDeviceInfo().getDescription()); result = 0; Thread.sleep(4000); - System.out.println("Close the keyboard. It may not work after this according to the docs!"); + LOGGER.debug("Close the keyboard. It may not work after this according to the docs!"); keyboard.close(); } else { - System.out.println("Could not find a keyboard."); + LOGGER.debug("Could not find a keyboard."); } return result; } diff --git a/tests/com/jsyn/ports/TestQueuedDataPort.java b/src/test/java/com/jsyn/ports/TestQueuedDataPort.java index e229038..65c0127 100644 --- a/tests/com/jsyn/ports/TestQueuedDataPort.java +++ b/src/test/java/com/jsyn/ports/TestQueuedDataPort.java @@ -16,40 +16,48 @@ package com.jsyn.ports; -import junit.framework.TestCase; - import com.jsyn.JSyn; import com.jsyn.Synthesizer; import com.jsyn.data.FloatSample; import com.jsyn.data.SequentialData; import com.jsyn.data.ShortSample; import com.jsyn.unitgen.FixedRateMonoReader; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test sample and envelope queuing and looping. * * @author Phil Burk, (C) 2009 Mobileer Inc */ -public class TestQueuedDataPort extends TestCase { - Synthesizer synth; - float[] floatData = { +public class TestQueuedDataPort { + + private static final Logger LOGGER = LoggerFactory.getLogger(TestQueuedDataPort.class); + + private static Synthesizer synth; + private static final float[] floatData = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f }; - FloatSample floatSample; - FixedRateMonoReader reader; + private static FloatSample floatSample; + private static FixedRateMonoReader reader; - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeAll + private static void setUp() { synth = JSyn.createSynthesizer(); synth.setRealTime(false); synth.start(); } - @Override - protected void tearDown() throws Exception { + @AfterAll + private static void tearDown() { synth.stop(); - super.tearDown(); } private void queueDirect(UnitDataQueuePort port, SequentialData data, int startFrame, @@ -64,6 +72,7 @@ public class TestQueuedDataPort extends TestCase { port.addQueuedBlock(command); } + @Test public void testQueueSingleShort() { short[] data = { 234, -9876, 4567 @@ -72,14 +81,15 @@ public class TestQueuedDataPort extends TestCase { sample.write(data); UnitDataQueuePort dataQueue = new UnitDataQueuePort("test"); - assertEquals("start empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "start empty"); queueDirect(dataQueue, sample, 0, data.length); checkQueuedData(data, dataQueue, 0, data.length); - assertEquals("end empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "end empty"); } + @Test public void testQueueSingleFloat() { float[] data = { 0.4f, 1.9f, 22.7f @@ -88,14 +98,15 @@ public class TestQueuedDataPort extends TestCase { sample.write(data); UnitDataQueuePort dataQueue = new UnitDataQueuePort("test"); - assertEquals("start empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "start empty"); queueDirect(dataQueue, sample, 0, data.length); checkQueuedData(data, dataQueue, 0, data.length); - assertEquals("end empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "end empty"); } + @Test public void testQueueOutOfBounds() { float[] data = { 0.4f, 1.9f, 22.7f @@ -110,7 +121,7 @@ public class TestQueuedDataPort extends TestCase { } catch(IllegalArgumentException e) { caught = true; } - assertTrue("expect exception when we go past end of the array", caught); + assertTrue(caught, "expect exception when we go past end of the array"); caught = false; try { @@ -118,7 +129,7 @@ public class TestQueuedDataPort extends TestCase { } catch(IllegalArgumentException e) { caught = true; } - assertTrue("expect exception when we go past end of the array", caught); + assertTrue(caught, "expect exception when we go past end of the array"); caught = false; try { @@ -126,9 +137,10 @@ public class TestQueuedDataPort extends TestCase { } catch(IllegalArgumentException e) { caught = true; } - assertTrue("expect exception when we start before beginning of the array", caught); + assertTrue(caught, "expect exception when we start before beginning of the array"); } + @Test public void testQueueMultiple() { short[] data = { 234, 17777, -9876, 4567, -14287 @@ -137,7 +149,7 @@ public class TestQueuedDataPort extends TestCase { sample.write(data); UnitDataQueuePort dataQueue = new UnitDataQueuePort("test"); - assertEquals("start empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "start empty"); queueDirect(dataQueue, sample, 1, 3); queueDirect(dataQueue, sample, 0, 5); @@ -147,11 +159,12 @@ public class TestQueuedDataPort extends TestCase { checkQueuedData(data, dataQueue, 0, 5); checkQueuedData(data, dataQueue, 2, 2); - assertEquals("end empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "end empty"); } + @Test public void testQueueNoLoops() throws InterruptedException { - System.out.println("testQueueNoLoops() ================"); + LOGGER.debug("testQueueNoLoops() ================"); UnitDataQueuePort dataQueue = setupFloatSample(); dataQueue.queueOn(floatSample, synth.createTimeStamp()); @@ -161,11 +174,12 @@ public class TestQueuedDataPort extends TestCase { // play entire sample checkQueuedData(floatData, dataQueue, 0, floatData.length); - assertEquals("end empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "end empty"); } + @Test public void testQueueLoopForever() throws InterruptedException { - System.out.println("testQueueLoopForever() ================"); + LOGGER.debug("testQueueLoopForever() ================"); UnitDataQueuePort dataQueue = setupFloatSample(); @@ -189,11 +203,12 @@ public class TestQueuedDataPort extends TestCase { // release portion will play checkQueuedData(floatData, dataQueue, 3, 5); - assertEquals("end empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "end empty"); } + @Test public void testQueueLoopAtLeastOnce() throws InterruptedException { - System.out.println("testQueueLoopAtLeastOnce() ================"); + LOGGER.debug("testQueueLoopAtLeastOnce() ================"); UnitDataQueuePort dataQueue = setupFloatSample(); @@ -208,11 +223,12 @@ public class TestQueuedDataPort extends TestCase { checkQueuedData(floatData, dataQueue, 3, 2); checkQueuedData(floatData, dataQueue, 5, 2); - assertEquals("end empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "end empty"); } + @Test public void testQueueNumLoops() throws InterruptedException { - System.out.println("testQueueNumLoops() ================"); + LOGGER.debug("testQueueNumLoops() ================"); UnitDataQueuePort dataQueue = setupFloatSample(); dataQueue.queue(floatSample, 0, 2); @@ -232,18 +248,18 @@ public class TestQueuedDataPort extends TestCase { checkQueuedData(floatData, dataQueue, 0, 2); for (int i = 0; i < (numLoopsA + 1); i++) { - System.out.println("loop A #" + i); + LOGGER.debug("loop A #" + i); checkQueuedData(floatData, dataQueue, 2, 3); } checkQueuedData(floatData, dataQueue, 4, 2); for (int i = 0; i < (numLoopsB + 1); i++) { - System.out.println("loop B #" + i); + LOGGER.debug("loop B #" + i); checkQueuedData(floatData, dataQueue, 3, 4); } checkQueuedData(floatData, dataQueue, 5, 2); - assertEquals("end empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "end empty"); } private UnitDataQueuePort setupFloatSample() { @@ -252,12 +268,13 @@ public class TestQueuedDataPort extends TestCase { synth.add(reader = new FixedRateMonoReader()); UnitDataQueuePort dataQueue = reader.dataQueue; - assertEquals("start empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "start empty"); return dataQueue; } + @Test public void testQueueSustainLoop() throws InterruptedException { - System.out.println("testQueueSustainLoop() ================"); + LOGGER.debug("testQueueSustainLoop() ================"); UnitDataQueuePort dataQueue = setupFloatSample(); @@ -280,11 +297,12 @@ public class TestQueuedDataPort extends TestCase { synth.sleepUntil(synth.getCurrentTime() + 0.01); checkQueuedData(floatData, dataQueue, 3, 5); // release - assertEquals("end empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "end empty"); } + @Test public void testQueueReleaseLoop() throws InterruptedException { - System.out.println("testQueueReleaseLoop() ================"); + LOGGER.debug("testQueueReleaseLoop() ================"); UnitDataQueuePort dataQueue = setupFloatSample(); // set up sustain loops =========================== @@ -308,11 +326,12 @@ public class TestQueuedDataPort extends TestCase { checkQueuedData(floatData, dataQueue, 4, 2); checkQueuedData(floatData, dataQueue, 4, 2); // still looping - assertEquals("end full", true, dataQueue.hasMore()); + assertTrue(dataQueue.hasMore(), "end full"); } + @Test public void testQueueSustainReleaseLoops() throws InterruptedException { - System.out.println("testQueueSustainReleaseLoops() ================"); + LOGGER.debug("testQueueSustainReleaseLoops() ================"); UnitDataQueuePort dataQueue = setupFloatSample(); // set up sustain loops =========================== @@ -335,28 +354,29 @@ public class TestQueuedDataPort extends TestCase { checkQueuedData(floatData, dataQueue, 3, 2); checkQueuedData(floatData, dataQueue, 5, 2); // release loop checkQueuedData(floatData, dataQueue, 5, 2); // release loop - assertEquals("end full", true, dataQueue.hasMore()); + assertTrue(dataQueue.hasMore(), "end full"); } + @Test private void checkQueuedData(short[] data, UnitDataQueuePort dataQueue, int offset, int numFrames) { for (int i = 0; i < numFrames; i++) { - assertEquals("got data", true, dataQueue.hasMore()); + assertTrue(dataQueue.hasMore(), "got data"); double value = dataQueue.readNextMonoDouble(synth.getFramePeriod()); - assertEquals("data matches", data[i + offset] / 32768.0, value, 0.0001); + assertEquals(data[i + offset] / 32768.0, value, 0.0001, "data matches"); } } private void checkQueuedData(float[] data, UnitDataQueuePort dataQueue, int offset, int numFrames) { for (int i = 0; i < numFrames; i++) { - assertEquals("got data", true, dataQueue.hasMore()); + assertTrue(dataQueue.hasMore(), "got data"); double value = dataQueue.readNextMonoDouble(synth.getFramePeriod()); - assertEquals("data matches", data[i + offset], value, 0.0001); + assertEquals(data[i + offset], value, 0.0001, "data matches"); } } - class TestQueueCallback implements UnitDataQueueCallback { + static class TestQueueCallback implements UnitDataQueueCallback { boolean gotStarted = false; boolean gotLooped = false; boolean gotFinished = false; @@ -364,26 +384,27 @@ public class TestQueuedDataPort extends TestCase { @Override public void started(QueueDataEvent event) { - System.out.println("Callback started."); + LOGGER.debug("Callback started."); gotStarted = true; lastEvent = event; } @Override public void looped(QueueDataEvent event) { - System.out.println("Callback looped."); + LOGGER.debug("Callback looped."); gotLooped = true; lastEvent = event; } @Override public void finished(QueueDataEvent event) { - System.out.println("Callback finished."); + LOGGER.debug("Callback finished."); gotFinished = true; lastEvent = event; } } + @Test public void testQueueCallback() { float[] data = { 0.2f, -8.9f, 2.7f @@ -392,7 +413,7 @@ public class TestQueuedDataPort extends TestCase { sample.write(data); UnitDataQueuePort dataQueue = new UnitDataQueuePort("test"); - assertEquals("start empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "start empty"); // Create an object to be called when the queued data is done. TestQueueCallback callback = new TestQueueCallback(); @@ -404,36 +425,37 @@ public class TestQueuedDataPort extends TestCase { // Check to see if flags get set true by callback. dataQueue.firePendingCallbacks(); - assertEquals("not started yet", false, callback.gotStarted); - assertEquals("not looped yet", false, callback.gotLooped); - assertEquals("not finished yet", false, callback.gotFinished); + assertFalse(callback.gotStarted, "not started yet"); + assertFalse(callback.gotLooped, "not looped yet"); + assertFalse(callback.gotFinished, "not finished yet"); checkQueuedData(data, dataQueue, 0, 1); dataQueue.firePendingCallbacks(); - assertEquals("should be started now", true, callback.gotStarted); - assertEquals("not looped yet", false, callback.gotLooped); - assertEquals("not finished yet", false, callback.gotFinished); - assertEquals("check source of event", dataQueue, callback.lastEvent.getSource()); - assertEquals("check sample", sample, callback.lastEvent.getSequentialData()); - assertEquals("check loopCount", 2, callback.lastEvent.getLoopsLeft()); + assertTrue(callback.gotStarted, "should be started now"); + assertFalse(callback.gotLooped, "not looped yet"); + assertFalse(callback.gotFinished, "not finished yet"); + assertEquals(dataQueue, callback.lastEvent.getSource(), "check source of event"); + assertEquals(sample, callback.lastEvent.getSequentialData(), "check sample"); + assertEquals(2, callback.lastEvent.getLoopsLeft(), "check loopCount"); checkQueuedData(data, dataQueue, 1, data.length - 1); dataQueue.firePendingCallbacks(); - assertEquals("should be looped now", true, callback.gotLooped); - assertEquals("check loopCount", 1, callback.lastEvent.getLoopsLeft()); - assertEquals("not finished yet", false, callback.gotFinished); + assertTrue(callback.gotLooped, "should be looped now"); + assertEquals(1, callback.lastEvent.getLoopsLeft(), "check loopCount"); + assertFalse(callback.gotFinished, "not finished yet"); checkQueuedData(data, dataQueue, 0, data.length); dataQueue.firePendingCallbacks(); - assertEquals("check loopCount", 0, callback.lastEvent.getLoopsLeft()); + assertEquals(0, callback.lastEvent.getLoopsLeft(), "check loopCount"); checkQueuedData(data, dataQueue, 0, data.length); dataQueue.firePendingCallbacks(); - assertEquals("should be finished now", true, callback.gotFinished); + assertTrue(callback.gotFinished, "should be finished now"); - assertEquals("end empty", false, dataQueue.hasMore()); + assertFalse(dataQueue.hasMore(), "end empty"); } + @Test public void testImmediate() { float[] data = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f @@ -455,6 +477,7 @@ public class TestQueuedDataPort extends TestCase { checkQueuedData(data, dataQueue, 7, 3); } + @Test public void testCrossFade() { float[] data1 = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f @@ -478,16 +501,17 @@ public class TestQueuedDataPort extends TestCase { for (int i = 0; i < 3; i++) { double factor = i / 3.0; double value = ((1.0 - factor) * data1[i + 4]) + (factor * data2[i + 1]); - System.out.println("i = " + i + ", factor = " + factor + ", value = " + value); + LOGGER.debug("i = " + i + ", factor = " + factor + ", value = " + value); double actual = dataQueue.readNextMonoDouble(synth.getFramePeriod()); - assertEquals("crossfade " + i, value, actual, 0.00001); + assertEquals(value, actual, 0.00001, "crossfade " + i); } // Should already be in new data. checkQueuedData(data2, dataQueue, 4, 5); } + @Test public void testImmediateCrossFade() { float[] data1 = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f @@ -513,10 +537,10 @@ public class TestQueuedDataPort extends TestCase { for (int i = 0; i < 3; i++) { double factor = i / 3.0; double value = ((1.0 - factor) * data1[i + beforeInterrupt]) + (factor * data2[i + 1]); - System.out.println("i = " + i + ", factor = " + factor + ", value = " + value); + LOGGER.debug("i = " + i + ", factor = " + factor + ", value = " + value); double actual = dataQueue.readNextMonoDouble(synth.getFramePeriod()); - assertEquals("crossfade " + i, value, actual, 0.00001); + assertEquals(value, actual, 0.00001, "crossfade " + i); } // Should already be in new data. diff --git a/tests/com/jsyn/ports/TestSequentialData.java b/src/test/java/com/jsyn/ports/TestSequentialData.java index 1328c78..2f27ec2 100644 --- a/tests/com/jsyn/ports/TestSequentialData.java +++ b/src/test/java/com/jsyn/ports/TestSequentialData.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,35 +16,40 @@ package com.jsyn.ports; -import junit.framework.TestCase; - import com.jsyn.data.FloatSample; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -public class TestSequentialData extends TestCase { +import static org.junit.jupiter.api.Assertions.assertEquals; - float[] data1 = { +public class TestSequentialData { + + private static final Logger LOGGER = LoggerFactory.getLogger(TestSequentialData.class); + + private final static float[] data1 = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f }; - FloatSample sample1; - float[] data2 = { + + private final static float[] data2 = { 20.0f, 19.0f, 18.0f, 17.0f, 16.0f, 15.0f, 14.0f, 13.0f, 12.0f, 11.0f }; - FloatSample sample2; + @Test public void testCrossfade() { - sample1 = new FloatSample(data1); - sample2 = new FloatSample(data2); + var sample1 = new FloatSample(data1); + var sample2 = new FloatSample(data2); SequentialDataCrossfade xfade = new SequentialDataCrossfade(); xfade.setup(sample1, 4, 3, sample2, 1, 6); for (int i = 0; i < 3; i++) { double factor = i / 3.0; double value = ((1.0 - factor) * data1[i + 4]) + (factor * data2[i + 1]); - System.out.println("i = " + i + ", factor = " + factor + ", value = " + value); - assertEquals("crossfade " + i, value, xfade.readDouble(i), 0.00001); + LOGGER.debug("i = " + i + ", factor = " + factor + ", value = " + value); + assertEquals(value, xfade.readDouble(i), 0.00001, "crossfade " + i); } for (int i = 3; i < 6; i++) { - assertEquals("crossfade " + i, sample2.readDouble(i + 1), xfade.readDouble(i), 0.00001); + assertEquals(sample2.readDouble(i + 1), xfade.readDouble(i), 0.00001, "crossfade " + i); } } } diff --git a/tests/com/jsyn/ports/TestSet.java b/src/test/java/com/jsyn/ports/TestSet.java index 8d1f3ea..be426b7 100644 --- a/tests/com/jsyn/ports/TestSet.java +++ b/src/test/java/com/jsyn/ports/TestSet.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,24 +16,17 @@ package com.jsyn.ports; -import junit.framework.TestCase; - import com.jsyn.engine.SynthesisEngine; import com.jsyn.unitgen.Minimum; +import org.junit.jupiter.api.Test; -public class TestSet extends TestCase { +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } +public class TestSet { /** Internal value setting. */ + @Test public void testSetValue() { int numParts = 4; UnitInputPort port = new UnitInputPort(numParts, "Tester"); @@ -41,12 +34,13 @@ public class TestSet extends TestCase { port.setValueInternal(2, 120.0); port.setValueInternal(1, 110.0); port.setValueInternal(3, 130.0); - assertEquals("check port value", 100.0, port.getValue(0)); - assertEquals("check port value", 120.0, port.getValue(2)); - assertEquals("check port value", 110.0, port.getValue(1)); - assertEquals("check port value", 130.0, port.getValue(3)); + assertEquals(100.0, port.getValue(0), "check port value"); + assertEquals(120.0, port.getValue(2), "check port value"); + assertEquals(110.0, port.getValue(1), "check port value"); + assertEquals(130.0, port.getValue(3), "check port value"); } + @Test public void testSet() throws InterruptedException { SynthesisEngine synthesisEngine = new SynthesisEngine(); synthesisEngine.setRealTime(false); @@ -60,16 +54,17 @@ public class TestSet extends TestCase { min.inputA.set(x); min.inputB.set(y); synthesisEngine.sleepFor(0.01); - assertEquals("min set A", x, min.inputA.getValue()); - assertEquals("min set B", y, min.inputB.getValue()); + assertEquals(x, min.inputA.getValue(), "min set A"); + assertEquals(y, min.inputB.getValue(), "min set B"); min.start(); synthesisEngine.sleepFor(0.01); - assertEquals("min output", y, min.output.getValue()); + assertEquals(y, min.output.getValue(), "min output"); synthesisEngine.stop(); } /** if we use a port index out of range we want to know now and not blow up the engine. */ + @Test public void testSetBadPort() throws InterruptedException { SynthesisEngine synthesisEngine = new SynthesisEngine(); synthesisEngine.setRealTime(false); @@ -78,14 +73,12 @@ public class TestSet extends TestCase { synthesisEngine.add(min = new Minimum()); min.start(); - Exception caught = null; try { min.inputA.set(1, 23.45); + } catch (ArrayIndexOutOfBoundsException ignored) { } catch (Exception e) { - caught = e; + fail("Catch port out of range, caught " + e); } - assertTrue("Catch port out of range, caught " + caught, - (caught instanceof ArrayIndexOutOfBoundsException)); // Don't blow up here. synthesisEngine.sleepUntil(0.01); diff --git a/tests/com/jsyn/research/BenchMultiThreading.java b/src/test/java/com/jsyn/research/BenchMultiThreading.java index 79b20bb..24624c5 100644 --- a/tests/com/jsyn/research/BenchMultiThreading.java +++ b/src/test/java/com/jsyn/research/BenchMultiThreading.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,17 +16,25 @@ package com.jsyn.research; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayList; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; + +// TODO: Use thread pools, or maybe JMH? +public class BenchMultiThreading { + + private static final Logger LOGGER = LoggerFactory.getLogger(BenchMultiThreading.class); -public class BenchMultiThreading extends TestCase { private static final int FRAMES_PER_BLOCK = 64; int numThreads = 4; int numLoops = 100000; private ArrayList<CustomThread> threadList; - class CustomThread extends Thread { + static class CustomThread extends Thread { long frameCount = 0; long desiredFrame = 0; Object semaphore = new Object(); @@ -52,7 +60,7 @@ public class BenchMultiThreading extends TestCase { synchronized (semaphore) { // Audio synthesis would occur here. frameCount += 1; - // System.out.println( this + " generating frame " + + // LOGGER.debug( this + " generating frame " + // frameCount ); semaphore.notify(); } @@ -64,9 +72,9 @@ public class BenchMultiThreading extends TestCase { long stopNano = System.nanoTime(); } } catch (InterruptedException e) { - System.out.println("CustomThread interrupted. "); + LOGGER.debug("CustomThread interrupted. "); } - System.out.println("Finishing " + this); + LOGGER.debug("Finishing " + this); } public void abort() { @@ -91,8 +99,9 @@ public class BenchMultiThreading extends TestCase { } + @Test public void testMultiThreads() { - threadList = new ArrayList<CustomThread>(); + threadList = new ArrayList<>(); for (int i = 0; i < numThreads; i++) { CustomThread thread = new CustomThread(); threadList.add(thread); @@ -105,7 +114,7 @@ public class BenchMultiThreading extends TestCase { for (int i = 0; i < numLoops; i++) { frameCount += 1; waitForThreads(frameCount); - // System.out.println("got frame " + frameCount ); + // LOGGER.debug("got frame " + frameCount ); } } catch (InterruptedException e) { e.printStackTrace(); @@ -124,7 +133,7 @@ public class BenchMultiThreading extends TestCase { (thread.maxElapsed / 1000000.0)); } for (CustomThread thread : threadList) { - assertEquals("BlockCount must match ", frameCount, thread.frameCount); + assertEquals(frameCount, thread.frameCount, "BlockCount must match "); thread.abort(); } diff --git a/tests/com/jsyn/research/RecordVariousRamps.java b/src/test/java/com/jsyn/research/RecordVariousRamps.java index c90ea9a..7abb2b1 100644 --- a/tests/com/jsyn/research/RecordVariousRamps.java +++ b/src/test/java/com/jsyn/research/RecordVariousRamps.java @@ -4,16 +4,16 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -/** +/** * Generate steps, linear ramps and smooth ramps. * * @author (C) 2014 Phil Burk @@ -36,8 +36,14 @@ import com.jsyn.unitgen.SawtoothOscillatorBL; import com.jsyn.unitgen.UnitFilter; import com.jsyn.unitgen.UnitOscillator; import com.jsyn.util.WaveRecorder; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RecordVariousRamps { + + private static final Logger LOGGER = LoggerFactory.getLogger(RecordVariousRamps.class); + private Synthesizer synth; private UnitOscillator osc; private Multiply multiplier; @@ -54,7 +60,7 @@ public class RecordVariousRamps { "step", "linear", "smooth" }; - private RampEvent[] rampData = { + private static final RampEvent[] rampData = { new RampEvent(1.0, 1.5, 2.0), new RampEvent(-0.9, 0.5, 1.0), new RampEvent(0.9, 0.5, 0.8), new RampEvent(-0.3, 0.5, 0.8), new RampEvent(0.9, 0.5, 0.3), new RampEvent(-0.5, 0.5, 0.3), @@ -81,7 +87,7 @@ public class RecordVariousRamps { File waveFile = new File("ramp_pitch_" + modeNames[mode] + ".wav"); // Mono 16 bits. recorder = new WaveRecorder(synth, waveFile, 1, 16); - System.out.println("Writing to 16-bit WAV file " + waveFile.getAbsolutePath()); + LOGGER.debug("Writing to 16-bit WAV file " + waveFile.getAbsolutePath()); // Add some tone generators. synth.add(osc = new SawtoothOscillatorBL()); @@ -153,7 +159,7 @@ public class RecordVariousRamps { ramp.getInput().set(rampEvent.target); nextEventTime += rampEvent.eventDuration; - System.out.println("target = " + rampEvent.target + ", rampDur = " + LOGGER.debug("target = " + rampEvent.target + ", rampDur = " + rampEvent.rampDuration + ", eventDur = " + rampEvent.eventDuration); try { synth.sleepUntil(nextEventTime); @@ -170,14 +176,18 @@ public class RecordVariousRamps { synth.stop(); } - public static void main(String[] args) { - try { - new RecordVariousRamps().test(MODE_STEP); - new RecordVariousRamps().test(MODE_LINEAR); - new RecordVariousRamps().test(MODE_SMOOTH); - } catch (IOException e) { - e.printStackTrace(); - } + @Test + private void stepMode() throws IOException { + test(MODE_STEP); } + @Test + public void linearMode() throws IOException { + test(MODE_LINEAR); + } + + @Test + public void smoothMode() throws IOException { + test(MODE_SMOOTH); + } } diff --git a/tests/com/jsyn/swing/TestRangeModels.java b/src/test/java/com/jsyn/swing/TestRangeModels.java index 8bcd021..5d12601 100644 --- a/tests/com/jsyn/swing/TestRangeModels.java +++ b/src/test/java/com/jsyn/swing/TestRangeModels.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,43 +16,36 @@ package com.jsyn.swing; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; -public class TestRangeModels extends TestCase { +import static org.junit.jupiter.api.Assertions.assertEquals; - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } +public class TestRangeModels { public void checkDoubleRange(double dmin, double dmax, double dval) { int resolution = 1000; DoubleBoundedRangeModel model = new DoubleBoundedRangeModel("test", resolution, dmin, dmax, dval); - assertEquals("setup min", dmin, model.getDoubleMinimum(), 0.0001); - assertEquals("setup max", dmax, model.getDoubleMaximum(), 0.0001); - assertEquals("setup value", dval, model.getDoubleValue(), 0.0001); + assertEquals(dmin, model.getDoubleMinimum(), 0.0001, "setup min"); + assertEquals(dmax, model.getDoubleMaximum(), 0.0001, "setup max"); + assertEquals(dval, model.getDoubleValue(), 0.0001, "setup value"); model.setDoubleValue(dmin); - assertEquals("min double value", dmin, model.getDoubleValue(), 0.0001); - assertEquals("min value", 0, model.getValue()); + assertEquals(dmin, model.getDoubleValue(), 0.0001, "min double value"); + assertEquals(0, model.getValue(), "min value"); double dmid = (dmax + dmin) / 2.0; model.setDoubleValue(dmid); - assertEquals("middle double value", dmid, model.getDoubleValue(), 0.0001); - assertEquals("middle value", resolution / 2, model.getValue()); + assertEquals(dmid, model.getDoubleValue(), 0.0001, "middle double value"); + assertEquals(resolution / 2, model.getValue(), "middle value"); model.setDoubleValue(dmax); - assertEquals("max double value", dmax, model.getDoubleValue(), 0.0001); - assertEquals("max value", resolution, model.getValue()); + assertEquals(dmax, model.getDoubleValue(), 0.0001, "max double value"); + assertEquals(resolution, model.getValue(), "max value"); } + @Test public void testDoubleRange() { checkDoubleRange(10.0, 20.0, 12.0); checkDoubleRange(-1.0, 1.0, 0.5); diff --git a/tests/com/jsyn/unitgen/CalibrateMoogFilter.java b/src/test/java/com/jsyn/unitgen/CalibrateMoogFilter.java index a830fcc..1e74aa8 100644 --- a/tests/com/jsyn/unitgen/CalibrateMoogFilter.java +++ b/src/test/java/com/jsyn/unitgen/CalibrateMoogFilter.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,7 +23,7 @@ import com.jsyn.Synthesizer; /** * Play a sawtooth through a 4-pole filter. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class CalibrateMoogFilter extends JApplet { @@ -134,7 +134,7 @@ public class CalibrateMoogFilter extends JApplet { } } - public static void main(String args[]) { + public static void main(String[] args) { new CalibrateMoogFilter().test(); } diff --git a/tests/com/jsyn/unitgen/EnablingGate.java b/src/test/java/com/jsyn/unitgen/EnablingGate.java index daf36be..daf36be 100644 --- a/tests/com/jsyn/unitgen/EnablingGate.java +++ b/src/test/java/com/jsyn/unitgen/EnablingGate.java diff --git a/tests/com/jsyn/unitgen/NonRealTimeTestCase.java b/src/test/java/com/jsyn/unitgen/NonRealTimeTestCase.java index 5d332a9..bec5762 100644 --- a/tests/com/jsyn/unitgen/NonRealTimeTestCase.java +++ b/src/test/java/com/jsyn/unitgen/NonRealTimeTestCase.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,11 +16,11 @@ package com.jsyn.unitgen; -import junit.framework.TestCase; - import com.jsyn.engine.SynthesisEngine; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; -public abstract class NonRealTimeTestCase extends TestCase { +public abstract class NonRealTimeTestCase { protected SynthesisEngine synthesisEngine; @@ -28,20 +28,14 @@ public abstract class NonRealTimeTestCase extends TestCase { super(); } - public NonRealTimeTestCase(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + private void setUp() { synthesisEngine = new SynthesisEngine(); synthesisEngine.setRealTime(false); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @AfterEach + private void tearDown() { synthesisEngine.stop(); } diff --git a/tests/com/jsyn/unitgen/RecordMoogFilter.java b/src/test/java/com/jsyn/unitgen/RecordMoogFilter.java index 6af11fd..31a86be 100644 --- a/tests/com/jsyn/unitgen/RecordMoogFilter.java +++ b/src/test/java/com/jsyn/unitgen/RecordMoogFilter.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,13 +25,18 @@ import javax.swing.JApplet; import com.jsyn.JSyn; import com.jsyn.Synthesizer; import com.jsyn.util.WaveRecorder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Measure actual frequency as a function of input frequency and Q. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class RecordMoogFilter extends JApplet { + + private static final Logger LOGGER = LoggerFactory.getLogger(RecordMoogFilter.class); + private final static boolean SWEEP_Q = false; private final static boolean SWEEP_FREQUENCY = true; private final static int NUM_STEPS = 11; @@ -77,7 +82,7 @@ public class RecordMoogFilter extends JApplet { // TODO Auto-generated catch block e.printStackTrace(); } - System.out.println("Writing to WAV file " + waveFile.getAbsolutePath()); + LOGGER.debug("Writing to WAV file " + waveFile.getAbsolutePath()); } @Override @@ -146,7 +151,7 @@ public class RecordMoogFilter extends JApplet { } } - public static void main(String args[]) { + public static void main(String[] args) { new RecordMoogFilter().test(); } diff --git a/tests/com/jsyn/unitgen/TestConnections.java b/src/test/java/com/jsyn/unitgen/TestConnections.java index d15a257..9aee32f 100644 --- a/tests/com/jsyn/unitgen/TestConnections.java +++ b/src/test/java/com/jsyn/unitgen/TestConnections.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,21 +16,22 @@ package com.jsyn.unitgen; -import junit.framework.TestCase; - import com.jsyn.JSyn; import com.jsyn.Synthesizer; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class TestConnections extends TestCase { - Add add1; - Add add2; - Add add3; +import static org.junit.jupiter.api.Assertions.assertEquals; - Synthesizer synth; +public class TestConnections { + private Synthesizer synth; - @Override - protected void setUp() throws Exception { - super.setUp(); + private Add add1; + private Add add2; + private Add add3; + + @BeforeEach + private void beforeEach() { synth = JSyn.createSynthesizer(); synth.add(add1 = new Add()); @@ -51,20 +52,17 @@ public class TestConnections extends TestCase { add3.inputB.set(3.2); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - + @Test public void testSet() throws InterruptedException { synth.sleepFor(0.01); - assertEquals("set inputs of adder", 0.3, add1.output.getValue(), 0.0001); + assertEquals(0.3, add1.output.getValue(), 0.0001, "set inputs of adder"); } + @Test public void testConnect() throws InterruptedException { synth.sleepFor(0.01); - assertEquals("set inputs of adder", 0.3, add1.output.getValue(), 0.0001); - assertEquals("set inputs of adder", 1.2, add2.output.getValue(), 0.0001); + assertEquals(0.3, add1.output.getValue(), 0.0001, "set inputs of adder"); + assertEquals(1.2, add2.output.getValue(), 0.0001, "set inputs of adder"); // Test different ways of connecting. add1.output.connect(add2.inputB); @@ -100,14 +98,14 @@ public class TestConnections extends TestCase { private void checkConnection() throws InterruptedException { synth.sleepFor(0.01); - assertEquals("connection should not change output", 0.3, add1.output.getValue(), 0.0001); - assertEquals("replace set value with output", 0.7, add2.output.getValue(), 0.0001); + assertEquals(0.3, add1.output.getValue(), 0.0001, "connection should not change output"); + assertEquals(0.7, add2.output.getValue(), 0.0001, "replace set value with output"); // Revert to set value after disconnection. add1.output.disconnectAll(); synth.sleepFor(0.01); - assertEquals("still the same", 0.3, add1.output.getValue(), 0.0001); - assertEquals("should revert to original set() value", 1.2, add2.output.getValue(), 0.0001); + assertEquals(0.3, add1.output.getValue(), 0.0001, "still the same"); + assertEquals(1.2, add2.output.getValue(), 0.0001, "should revert to original set() value"); } } diff --git a/tests/com/jsyn/unitgen/TestDelay.java b/src/test/java/com/jsyn/unitgen/TestDelay.java index 12af1cd..7e1a0b1 100644 --- a/tests/com/jsyn/unitgen/TestDelay.java +++ b/src/test/java/com/jsyn/unitgen/TestDelay.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,12 +17,17 @@ package com.jsyn.unitgen; import com.jsyn.util.AudioStreamReader; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class TestDelay extends NonRealTimeTestCase { + + @Test public void testFloor() { double x = -7.3; int n = (int) Math.floor(x); - assertEquals("int", -8, n); + assertEquals(-8, n, "int"); } public void checkInterpolatingDelay(int maxFrames, double delayFrames) @@ -55,18 +60,21 @@ public class TestDelay extends NonRealTimeTestCase { expected = 0.0; } // System.out.printf( "[%d] expected = %7.3f, delayed = %7.3f\n", i, expected, actual ); - // assertEquals("delayed output", expected, actual, 0.00001); + // assertEquals(expected, actual, 0.00001, "delayed output"); } } + @Test public void testSmall() throws InterruptedException { checkInterpolatingDelay(40, 7.0); } + @Test public void testEven() throws InterruptedException { checkInterpolatingDelay(44100, 13671.0); } + @Test public void testInterpolatingDelay() throws InterruptedException { checkInterpolatingDelay(44100, 13671.4); } diff --git a/tests/com/jsyn/unitgen/TestEnable.java b/src/test/java/com/jsyn/unitgen/TestEnable.java index 37a4a2b..a244c61 100644 --- a/tests/com/jsyn/unitgen/TestEnable.java +++ b/src/test/java/com/jsyn/unitgen/TestEnable.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,26 +16,29 @@ package com.jsyn.unitgen; -import junit.framework.TestCase; - import com.jsyn.engine.SynthesisEngine; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; -public class TestEnable extends TestCase { - SynthesisEngine synthesisEngine; +public class TestEnable { + private SynthesisEngine synthesisEngine; - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + protected void beforeEach() { synthesisEngine = new SynthesisEngine(); synthesisEngine.setRealTime(false); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @AfterEach + protected void afterEach() { synthesisEngine.stop(); } + @Test public void testEnablingGate() throws InterruptedException { LinearRamp ramp = new LinearRamp(); synthesisEngine.add(ramp); @@ -59,20 +62,20 @@ public class TestEnable extends TestCase { adder.start(); synthesisEngine.sleepUntil(startTime + 0.1); double tolerance = 0.002; - assertEquals("ramp going up", 0.1, ramp.output.getValue(), tolerance); - assertEquals("enabler going up", 0.1, enabler.output.getValue(), tolerance); - assertEquals("adder going up", 0.1, adder.output.getValue(), tolerance); + assertEquals(0.1, ramp.output.getValue(), tolerance, "ramp going up"); + assertEquals(0.1, enabler.output.getValue(), tolerance, "enabler going up"); + assertEquals(0.1, adder.output.getValue(), tolerance, "adder going up"); synthesisEngine.sleepUntil(startTime + 0.2); - assertEquals("start enabled", 0.2, adder.output.getValue(), tolerance); + assertEquals(0.2, adder.output.getValue(), tolerance, "start enabled"); // disable everything upstream enabler.gate.set(0.0); synthesisEngine.sleepUntil(startTime + 0.3); - assertEquals("should not be pulled", 0.2, ramp.output.getValue(), tolerance); - assertEquals("should be disabled", false, enabler.isEnabled()); - assertEquals("should be zero", 0.0, enabler.output.getValue(), tolerance); - assertEquals("zero", 0.0, adder.output.getValue(), tolerance); + assertEquals(0.2, ramp.output.getValue(), tolerance, "should not be pulled"); + assertFalse(enabler.isEnabled(), "should be disabled"); + assertEquals(0.0, enabler.output.getValue(), tolerance, "should be zero"); + assertEquals(0.0, adder.output.getValue(), tolerance, "zero"); } } diff --git a/tests/com/jsyn/unitgen/TestEnvelopeAttackDecay.java b/src/test/java/com/jsyn/unitgen/TestEnvelopeAttackDecay.java index 50ecb15..8328bb7 100644 --- a/tests/com/jsyn/unitgen/TestEnvelopeAttackDecay.java +++ b/src/test/java/com/jsyn/unitgen/TestEnvelopeAttackDecay.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,28 +17,33 @@ package com.jsyn.unitgen; import com.jsyn.engine.SynthesisEngine; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestEnvelopeAttackDecay extends TestUnitGate { double attackTime; double decayTime; - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + protected void beforeEach() { synthesisEngine = new SynthesisEngine(); synthesisEngine.setRealTime(false); attackTime = 0.2; decayTime = 0.4; } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @AfterEach + protected void afterEach() { synthesisEngine.stop(); } + @Test public void testOnOff() throws InterruptedException { - EnvelopeAttackDecay envelope = new EnvelopeAttackDecay(); + var envelope = new EnvelopeAttackDecay(); synthesisEngine.add(envelope); envelope.attack.set(0.1); @@ -48,18 +53,18 @@ public class TestEnvelopeAttackDecay extends TestUnitGate { envelope.start(); time = synthesisEngine.getCurrentTime(); synthesisEngine.sleepUntil(time + 0.1); - assertEquals("still idling", 0.0, envelope.output.getValue()); + assertEquals(0.0, envelope.output.getValue(), "still idling"); // Trigger the envelope using on/off envelope.input.on(); time = synthesisEngine.getCurrentTime(); // Check end of attack cycle. synthesisEngine.sleepUntil(time + 0.1); - assertTrue("at peak", (envelope.output.getValue() > 0.8)); + assertTrue(envelope.output.getValue() > 0.8, "at peak"); envelope.input.off(); // Check end of decay cycle. synthesisEngine.sleepUntil(time + 0.3); - assertTrue("at peak", (envelope.output.getValue() < 0.1)); + assertTrue(envelope.output.getValue() < 0.1, "at peak"); synthesisEngine.sleepFor(0.1); @@ -68,15 +73,15 @@ public class TestEnvelopeAttackDecay extends TestUnitGate { time = synthesisEngine.getCurrentTime(); // Check end of attack cycle. synthesisEngine.sleepUntil(time + 0.1); - assertTrue("at peak", (envelope.output.getValue() > 0.8)); + assertTrue(envelope.output.getValue() > 0.8, "at peak"); // Check end of decay cycle. synthesisEngine.sleepUntil(time + 0.3); - assertTrue("at peak", (envelope.output.getValue() < 0.1)); - + assertTrue(envelope.output.getValue() < 0.1, "at peak"); } + @Test public void testRetrigger() throws InterruptedException { - EnvelopeAttackDecay envelope = new EnvelopeAttackDecay(); + var envelope = new EnvelopeAttackDecay(); synthesisEngine.add(envelope); envelope.attack.set(0.1); @@ -86,41 +91,40 @@ public class TestEnvelopeAttackDecay extends TestUnitGate { envelope.start(); time = synthesisEngine.getCurrentTime(); synthesisEngine.sleepUntil(time + 0.1); - assertEquals("still idling", 0.0, envelope.output.getValue()); + assertEquals(0.0, envelope.output.getValue(), "still idling"); // Trigger the envelope using trigger() envelope.input.trigger(); // Check end of attack cycle. synthesisEngine.sleepFor(0.1); - assertEquals("at peak", 1.0, envelope.output.getValue(), 0.1); + assertEquals(1.0, envelope.output.getValue(), 0.1, "at peak"); // Decay half way. synthesisEngine.sleepFor(0.1); - assertTrue("at peak", (envelope.output.getValue() < 0.7)); + assertTrue(envelope.output.getValue() < 0.7, "at peak"); // Retrigger while decaying envelope.input.trigger(); // Will get to top faster. synthesisEngine.sleepFor(0.1); - assertEquals("at peak", 1.0, envelope.output.getValue(), 0.1); + assertEquals(1.0, envelope.output.getValue(), 0.1, "at peak"); // Check end of decay cycle. synthesisEngine.sleepFor(0.2); - assertTrue("at peak", (envelope.output.getValue() < 0.1)); + assertTrue(envelope.output.getValue() < 0.1, "at peak"); } + @Test public void testAutoDisable() throws InterruptedException { - - LinearRamp ramp = new LinearRamp(); + var ramp = new LinearRamp(); synthesisEngine.add(ramp); - EnvelopeAttackDecay envelope = new EnvelopeAttackDecay(); + var envelope = new EnvelopeAttackDecay(); envelope.attack.set(0.1); envelope.decay.set(0.1); synthesisEngine.add(envelope); ramp.output.connect(envelope.amplitude); checkAutoDisable(ramp, envelope); - } } diff --git a/tests/com/jsyn/unitgen/TestEnvelopeDAHDSR.java b/src/test/java/com/jsyn/unitgen/TestEnvelopeDAHDSR.java index 8c781ac..618e823 100644 --- a/tests/com/jsyn/unitgen/TestEnvelopeDAHDSR.java +++ b/src/test/java/com/jsyn/unitgen/TestEnvelopeDAHDSR.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,8 +17,19 @@ package com.jsyn.unitgen; import com.jsyn.engine.SynthesisEngine; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestEnvelopeDAHDSR extends TestUnitGate { + + private static final Logger LOGGER = LoggerFactory.getLogger(TestEnvelopeDAHDSR.class); + double delayTime; double attackTime; double holdTime; @@ -26,9 +37,8 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { double sustainLevel; double releaseTime; - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + protected void beforeEach() { synthesisEngine = new SynthesisEngine(); synthesisEngine.setRealTime(false); delayTime = 0.1; @@ -39,12 +49,12 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { releaseTime = 0.6; } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @AfterEach + protected void afterEach() { synthesisEngine.stop(); } + @Test public void testStages() throws InterruptedException { EnvelopeDAHDSR ramp = checkToSustain(); @@ -53,13 +63,13 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { ramp.sustain.set(sustainLevel); time += 0.01; synthesisEngine.sleepUntil(time); - assertEquals("sustain moving delaying", sustainLevel, ramp.output.getValue(), 0.01); + assertEquals(sustainLevel, ramp.output.getValue(), 0.01, "sustain moving delaying"); // Gate off to let envelope release. ramp.input.set(0.0); synthesisEngine.sleepUntil(time + (releaseTime * 0.1)); double releaseValue = ramp.output.getValue(); - assertEquals("partway down release", sustainLevel * 0.36, releaseValue, 0.01); + assertEquals(sustainLevel * 0.36, releaseValue, 0.01, "partway down release"); } private EnvelopeDAHDSR checkToSustain() throws InterruptedException { @@ -77,28 +87,29 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { ramp.start(); time = synthesisEngine.getCurrentTime(); synthesisEngine.sleepUntil(time + (2.0 * delayTime)); - assertEquals("still idling", 0.0, ramp.output.getValue()); + assertEquals(0.0, ramp.output.getValue(), "still idling"); // Trigger the envelope. ramp.input.set(1.0); time = synthesisEngine.getCurrentTime(); // Check end of delay cycle. synthesisEngine.sleepUntil(time + (delayTime * 0.9)); - assertEquals("still delaying", 0.0, ramp.output.getValue(), 0.01); + assertEquals(0.0, ramp.output.getValue(), 0.01, "still delaying"); // Half way up attack ramp. synthesisEngine.sleepUntil(time + delayTime + (attackTime * 0.5)); - assertEquals("half attack", 0.5, ramp.output.getValue(), 0.01); + assertEquals(0.5, ramp.output.getValue(), 0.01, "half attack"); // Holding after attack. synthesisEngine.sleepUntil(time + delayTime + attackTime + (holdTime * 0.1)); - assertEquals("holding", 1.0, ramp.output.getValue(), 0.01); + assertEquals(1.0, ramp.output.getValue(), 0.01, "holding"); synthesisEngine.sleepUntil(time + delayTime + attackTime + (holdTime * 0.9)); - assertEquals("still holding", 1.0, ramp.output.getValue(), 0.01); + assertEquals(1.0, ramp.output.getValue(), 0.01, "still holding"); synthesisEngine.sleepUntil(time + delayTime + attackTime + holdTime + decayTime); time = synthesisEngine.getCurrentTime(); - assertEquals("at sustain", sustainLevel, ramp.output.getValue(), 0.01); + assertEquals(sustainLevel, ramp.output.getValue(), 0.01, "at sustain"); return ramp; } + @Test public void testRetrigger() throws InterruptedException { EnvelopeDAHDSR ramp = checkToSustain(); @@ -106,21 +117,22 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { ramp.input.set(0.0); synthesisEngine.sleepUntil(time + (releaseTime * 0.1)); double releaseValue = ramp.output.getValue(); - assertEquals("partway down release", sustainLevel * 0.36, releaseValue, 0.01); + assertEquals(sustainLevel * 0.36, releaseValue, 0.01, "partway down release"); // Retrigger during release phase. time = synthesisEngine.getCurrentTime(); ramp.input.set(1.0); // Check end of delay cycle. synthesisEngine.sleepUntil(time + (delayTime * 0.9)); - assertEquals("still delaying", releaseValue, ramp.output.getValue(), 0.01); + assertEquals(releaseValue, ramp.output.getValue(), 0.01, "still delaying"); // Half way up attack ramp from where it started. synthesisEngine.sleepUntil(time + delayTime + (attackTime * 0.5)); - assertEquals("half attack", releaseValue + 0.5, ramp.output.getValue(), 0.01); + assertEquals(releaseValue + 0.5, ramp.output.getValue(), 0.01, "half attack"); } // I noticed a hang while playing with knobs. + @Test public void testHang() throws InterruptedException { delayTime = 0.0; @@ -146,13 +158,13 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { ramp.input.set(1.0); time = synthesisEngine.getCurrentTime(); synthesisEngine.sleepUntil(time + 0.01); - assertEquals("should jump to sustain level", sustainLevel, ramp.output.getValue()); + assertEquals(sustainLevel, ramp.output.getValue(), "should jump to sustain level"); // Gate off to let envelope release. ramp.input.set(0.0); synthesisEngine.sleepUntil(time + 1.0); double releaseValue = ramp.output.getValue(); - assertTrue("partway down release", sustainLevel > releaseValue); + assertTrue(sustainLevel > releaseValue, "partway down release"); holdTime = 0.5; ramp.hold.set(holdTime); @@ -164,9 +176,10 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { ramp.input.set(1.0); // Check end of delay cycle. synthesisEngine.sleepUntil(time + (holdTime * 0.1)); - assertEquals("should jump to hold", 1.0, ramp.output.getValue(), 0.01); + assertEquals(1.0, ramp.output.getValue(), 0.01, "should jump to hold"); } + @Test public void testNegative() throws InterruptedException { delayTime = -0.1; attackTime = -0.2; @@ -192,26 +205,27 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { time = synthesisEngine.getCurrentTime(); time += 0.1; synthesisEngine.sleepUntil(time + 0.01); - assertEquals("should jump to sustain level", sustainLevel, ramp.output.getValue()); + assertEquals(sustainLevel, ramp.output.getValue(), "should jump to sustain level"); ramp.sustain.set(sustainLevel = -0.4); time += 0.1; synthesisEngine.sleepUntil(time); - assertEquals("sustain should clip at zero", sustainLevel, ramp.output.getValue()); + assertEquals(sustainLevel, ramp.output.getValue(), "sustain should clip at zero"); ramp.sustain.set(sustainLevel = 0.4); time += 0.1; synthesisEngine.sleepUntil(time); - assertEquals("sustain should come back", sustainLevel, ramp.output.getValue()); + assertEquals(sustainLevel, ramp.output.getValue(), "sustain should come back"); // Gate off to let envelope release. ramp.input.set(0.0); time += 0.1; synthesisEngine.sleepUntil(time); double releaseValue = ramp.output.getValue(); - assertEquals("release quickly", 0.0, releaseValue); + assertEquals(0.0, releaseValue, "release quickly"); } + @Test public void testOnOff() throws InterruptedException { EnvelopeDAHDSR ramp = new EnvelopeDAHDSR(); synthesisEngine.add(ramp); @@ -227,23 +241,24 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { ramp.start(); time = synthesisEngine.getCurrentTime(); synthesisEngine.sleepUntil(time + 0.2); - assertEquals("still idling", 0.0, ramp.output.getValue()); + assertEquals(0.0, ramp.output.getValue(), "still idling"); // Trigger the envelope. ramp.input.on(); time = synthesisEngine.getCurrentTime(); // Check end of delay cycle. synthesisEngine.sleepUntil(time + 0.2); - assertEquals("at sustain", 0.9, ramp.output.getValue(), 0.01); + assertEquals(0.9, ramp.output.getValue(), 0.01, "at sustain"); // Release the envelope. ramp.input.off(); time = synthesisEngine.getCurrentTime(); // Check end of delay cycle. synthesisEngine.sleepUntil(time + 0.2); - assertEquals("after release", 0.0, ramp.output.getValue(), 0.01); + assertEquals(0.0, ramp.output.getValue(), 0.01, "after release"); } + @Test public void testAutoDisable() throws InterruptedException { LinearRamp ramp = new LinearRamp(); @@ -257,10 +272,9 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { ramp.output.connect(envelope.amplitude); checkAutoDisable(ramp, envelope); - } - class GatedRampCircuit extends Circuit { + static class GatedRampCircuit extends Circuit { LinearRamp ramp; EnvelopeDAHDSR envelope; @@ -277,6 +291,7 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { } } + @Test public void testAutoDisableCircuit() throws InterruptedException { GatedRampCircuit circuit = new GatedRampCircuit(); synthesisEngine.add(circuit); @@ -308,12 +323,12 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { time = synthesisEngine.getCurrentTime(); time += attackTime * 2; synthesisEngine.sleepUntil(time); - assertEquals("should be at to sustain level", sustainLevel, ramp.output.getValue()); + assertEquals(sustainLevel, ramp.output.getValue(), "should be at to sustain level"); // Start envelope release. ramp.input.set(0.0); final double db90 = 20.0 * Math.log(1.0 / 32768.0) / Math.log(10.0); - System.out.println("JSyns DB90 is actually " + db90); + LOGGER.debug("JSyns DB90 is actually " + db90); int numSteps = 10; for (int i = 0; i < 10; i++) { time += releaseTime / numSteps; @@ -321,14 +336,15 @@ public class TestEnvelopeDAHDSR extends TestUnitGate { double expectedDB = db90 * (i + 1) / numSteps; double expectedAmplitude = sustainLevel * Math.pow(10.0, expectedDB / 20.0); double releaseValue = ramp.output.getValue(); - assertEquals("release " + i + " at", expectedAmplitude, releaseValue, tolerance); + assertEquals(expectedAmplitude, releaseValue, tolerance, "release " + i + " at"); } time += releaseTime / numSteps; synthesisEngine.sleepUntil(time); double releaseValue = ramp.output.getValue(); - assertEquals("env after release time should go to zero", 0.0, releaseValue, 0.0001); + assertEquals(0.0, releaseValue, 0.0001, "env after release time should go to zero"); } + @Test public void testReleaseTiming() throws InterruptedException { checkReleaseTiming(0.1, 0.004); checkReleaseTiming(1.0, 0.002); diff --git a/tests/com/jsyn/unitgen/TestFunction.java b/src/test/java/com/jsyn/unitgen/TestFunction.java index a8bfac0..65953cd 100644 --- a/tests/com/jsyn/unitgen/TestFunction.java +++ b/src/test/java/com/jsyn/unitgen/TestFunction.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,63 +16,62 @@ package com.jsyn.unitgen; -import junit.framework.TestCase; - import com.jsyn.JSyn; import com.jsyn.Synthesizer; import com.jsyn.data.DoubleTable; import com.jsyn.data.Function; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Phil Burk, (C) 2009 Mobileer Inc */ -public class TestFunction extends TestCase { +public class TestFunction { Synthesizer synth; - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + protected void beforeEach() { synth = JSyn.createSynthesizer(); synth.setRealTime(false); synth.start(); } - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void afterEach() { synth.stop(); } + @Test public void testDoubleTable() { double[] data = { 2.0, 0.0, 3.0 }; DoubleTable table = new DoubleTable(data); - assertEquals("DoubleTable below", 2.0, table.evaluate(-1.4)); - assertEquals("DoubleTable edge", 2.0, table.evaluate(-1.0)); - assertEquals("DoubleTable mid", 1.0, table.evaluate(-0.5)); - assertEquals("DoubleTable zero", 0.0, table.evaluate(0.0)); - assertEquals("DoubleTable mid", 0.75, table.evaluate(0.25)); - assertEquals("DoubleTable above", 3.0, table.evaluate(1.3)); + assertEquals(2.0, table.evaluate(-1.4), "DoubleTable below"); + assertEquals(2.0, table.evaluate(-1.0), "DoubleTable edge"); + assertEquals(1.0, table.evaluate(-0.5), "DoubleTable mid"); + assertEquals(0.0, table.evaluate(0.0), "DoubleTable zero"); + assertEquals(0.75, table.evaluate(0.25), "DoubleTable mid"); + assertEquals(3.0, table.evaluate(1.3), "DoubleTable above"); } + @Test public void testFunctionEvaluator() throws InterruptedException { FunctionEvaluator shaper = new FunctionEvaluator(); synth.add(shaper); shaper.start(); - Function cuber = new Function() { - @Override - public double evaluate(double x) { - return x * x * x; - } - }; + Function cuber = x -> x * x * x; shaper.function.set(cuber); shaper.input.set(0.5); synth.sleepFor(0.001); - assertEquals("Cuber", (0.5 * 0.5 * 0.5), shaper.output.getValue()); + assertEquals((0.5 * 0.5 * 0.5), shaper.output.getValue(), "Cuber"); } } diff --git a/tests/com/jsyn/unitgen/TestMath.java b/src/test/java/com/jsyn/unitgen/TestMath.java index cae1dea..7c33223 100644 --- a/tests/com/jsyn/unitgen/TestMath.java +++ b/src/test/java/com/jsyn/unitgen/TestMath.java @@ -16,28 +16,25 @@ package com.jsyn.unitgen; -import junit.framework.TestCase; - import com.jsyn.engine.SynthesisEngine; import com.softsynth.math.AudioMath; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Phil Burk, (C) 2009 Mobileer Inc */ -public class TestMath extends TestCase { +public class TestMath { SynthesisEngine synthesisEngine; - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + protected void beforeEach() { synthesisEngine = new SynthesisEngine(); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - + @Test public void testAdd() { Add add = new Add(); add.setSynthesisEngine(synthesisEngine); @@ -49,9 +46,10 @@ public class TestMath extends TestCase { add.generate(); - assertEquals("Add", x + y, add.output.getValue(), 0.001); + assertEquals(x + y, add.output.getValue(), 0.001, "Add"); } + @Test public void testPartialAdd() { Add add = new Add(); add.setSynthesisEngine(synthesisEngine); @@ -66,20 +64,21 @@ public class TestMath extends TestCase { // Only generate values for 2,3,4 add.generate(2, 5); - assertEquals("Add partial", 0.0, add.output.getValues()[0], 0.001); - assertEquals("Add partial", 0.0, add.output.getValues()[1], 0.001); - assertEquals("Add partial", x + y, add.output.getValues()[2], 0.001); - assertEquals("Add partial", x + y, add.output.getValues()[3], 0.001); - assertEquals("Add partial", x + y, add.output.getValues()[4], 0.001); - assertEquals("Add partial", 0.0, add.output.getValues()[5], 0.001); - assertEquals("Add partial", 0.0, add.output.getValues()[6], 0.001); - assertEquals("Add partial", 0.0, add.output.getValues()[7], 0.001); + assertEquals(0.0, add.output.getValues()[0], 0.001, "Add partial"); + assertEquals(0.0, add.output.getValues()[1], 0.001, "Add partial"); + assertEquals(x + y, add.output.getValues()[2], 0.001, "Add partial"); + assertEquals(x + y, add.output.getValues()[3], 0.001, "Add partial"); + assertEquals(x + y, add.output.getValues()[4], 0.001, "Add partial"); + assertEquals(0.0, add.output.getValues()[5], 0.001, "Add partial"); + assertEquals(0.0, add.output.getValues()[6], 0.001, "Add partial"); + assertEquals(0.0, add.output.getValues()[7], 0.001, "Add partial"); } /** * Unit test for Subtract.java - added by Lisa Tolentino 06/17/2009 */ + @Test public void testSubtract() { Subtract sub = new Subtract(); sub.setSynthesisEngine(synthesisEngine); @@ -91,9 +90,10 @@ public class TestMath extends TestCase { sub.generate(); - assertEquals("Subtract", x - y, sub.output.getValue(), 0.001); + assertEquals(x - y, sub.output.getValue(), 0.001, "Subtract"); } + @Test public void testPartialSubtract() { Subtract sub = new Subtract(); sub.setSynthesisEngine(synthesisEngine); @@ -108,20 +108,20 @@ public class TestMath extends TestCase { // Only generate values for 2,3,4 sub.generate(2, 5); - assertEquals("Subtract partial", 0.0, sub.output.getValues()[0], 0.001); - assertEquals("Subtract partial", 0.0, sub.output.getValues()[1], 0.001); - assertEquals("Subtract partial", x - y, sub.output.getValues()[2], 0.001); - assertEquals("Subtract partial", x - y, sub.output.getValues()[3], 0.001); - assertEquals("Subtract partial", x - y, sub.output.getValues()[4], 0.001); - assertEquals("Subtract partial", 0.0, sub.output.getValues()[5], 0.001); - assertEquals("Subtract partial", 0.0, sub.output.getValues()[6], 0.001); - assertEquals("Subtract partial", 0.0, sub.output.getValues()[7], 0.001); - + assertEquals(0.0, sub.output.getValues()[0], 0.001, "Subtract partial"); + assertEquals(0.0, sub.output.getValues()[1], 0.001, "Subtract partial"); + assertEquals(x - y, sub.output.getValues()[2], 0.001, "Subtract partial"); + assertEquals(x - y, sub.output.getValues()[3], 0.001, "Subtract partial"); + assertEquals(x - y, sub.output.getValues()[4], 0.001, "Subtract partial"); + assertEquals(0.0, sub.output.getValues()[5], 0.001, "Subtract partial"); + assertEquals(0.0, sub.output.getValues()[6], 0.001, "Subtract partial"); + assertEquals(0.0, sub.output.getValues()[7], 0.001, "Subtract partial"); } /** * Unit test for Multiply.java - added by Lisa Tolentino 06/19/2009 */ + @Test public void testMultiply() { Multiply mult = new Multiply(); mult.setSynthesisEngine(synthesisEngine); @@ -133,9 +133,10 @@ public class TestMath extends TestCase { mult.generate(); - assertEquals("Multiply", x * y, mult.output.getValue(), 0.001); + assertEquals(x * y, mult.output.getValue(), 0.001, "Multiply"); } + @Test public void testPartialMultiply() { Multiply mult = new Multiply(); mult.setSynthesisEngine(synthesisEngine); @@ -150,20 +151,20 @@ public class TestMath extends TestCase { // Only generate values for 2,3,4 mult.generate(2, 5); - assertEquals("Multiply partial", 0.0, mult.output.getValues()[0], 0.001); - assertEquals("Multiply partial", 0.0, mult.output.getValues()[1], 0.001); - assertEquals("Multiply partial", x * y, mult.output.getValues()[2], 0.001); - assertEquals("Multiply partial", x * y, mult.output.getValues()[3], 0.001); - assertEquals("Multiply partial", x * y, mult.output.getValues()[4], 0.001); - assertEquals("Multiply partial", 0.0, mult.output.getValues()[5], 0.001); - assertEquals("Multiply partial", 0.0, mult.output.getValues()[6], 0.001); - assertEquals("Multiply partial", 0.0, mult.output.getValues()[7], 0.001); - + assertEquals(0.0, mult.output.getValues()[0], 0.001, "Multiply partial"); + assertEquals(0.0, mult.output.getValues()[1], 0.001, "Multiply partial"); + assertEquals(x * y, mult.output.getValues()[2], 0.001, "Multiply partial"); + assertEquals(x * y, mult.output.getValues()[3], 0.001, "Multiply partial"); + assertEquals(x * y, mult.output.getValues()[4], 0.001, "Multiply partial"); + assertEquals(0.0, mult.output.getValues()[5], 0.001, "Multiply partial"); + assertEquals(0.0, mult.output.getValues()[6], 0.001, "Multiply partial"); + assertEquals(0.0, mult.output.getValues()[7], 0.001, "Multiply partial"); } /** * Unit test for Divide.java - added by Lisa Tolentino 06/19/2009 */ + @Test public void testDivide() { Divide divide = new Divide(); divide.setSynthesisEngine(synthesisEngine); @@ -175,9 +176,10 @@ public class TestMath extends TestCase { divide.generate(); - assertEquals("Divide", x / y, divide.output.getValue(), 0.001); + assertEquals(x / y, divide.output.getValue(), 0.001, "Divide"); } + @Test public void testPartialDivide() { Divide divide = new Divide(); divide.setSynthesisEngine(synthesisEngine); @@ -192,20 +194,20 @@ public class TestMath extends TestCase { // Only generate values for 2,3,4 divide.generate(2, 5); - assertEquals("Divide partial", 0.0, divide.output.getValues()[0], 0.001); - assertEquals("Divide partial", 0.0, divide.output.getValues()[1], 0.001); - assertEquals("Divide partial", x / y, divide.output.getValues()[2], 0.001); - assertEquals("Divide partial", x / y, divide.output.getValues()[3], 0.001); - assertEquals("Divide partial", x / y, divide.output.getValues()[4], 0.001); - assertEquals("Divide partial", 0.0, divide.output.getValues()[5], 0.001); - assertEquals("Divide partial", 0.0, divide.output.getValues()[6], 0.001); - assertEquals("Divide partial", 0.0, divide.output.getValues()[7], 0.001); - + assertEquals(0.0, divide.output.getValues()[0], 0.001, "Divide partial"); + assertEquals(0.0, divide.output.getValues()[1], 0.001, "Divide partial"); + assertEquals(x / y, divide.output.getValues()[2], 0.001, "Divide partial"); + assertEquals(x / y, divide.output.getValues()[3], 0.001, "Divide partial"); + assertEquals(x / y, divide.output.getValues()[4], 0.001, "Divide partial"); + assertEquals(0.0, divide.output.getValues()[5], 0.001, "Divide partial"); + assertEquals(0.0, divide.output.getValues()[6], 0.001, "Divide partial"); + assertEquals(0.0, divide.output.getValues()[7], 0.001, "Divide partial"); } /** * Unit test for MultiplyAdd.java - added by Lisa Tolentino 06/19/2009 */ + @Test public void testMultiplyAdd() { MultiplyAdd multAdd = new MultiplyAdd(); multAdd.setSynthesisEngine(synthesisEngine); @@ -219,9 +221,10 @@ public class TestMath extends TestCase { multAdd.generate(); - assertEquals("MultiplyAdd", (x * y) + z, multAdd.output.getValue(), 0.001); + assertEquals((x * y) + z, multAdd.output.getValue(), 0.001, "MultiplyAdd"); } + @Test public void testPartialMultiplyAdd() { MultiplyAdd multAdd = new MultiplyAdd(); multAdd.setSynthesisEngine(synthesisEngine); @@ -238,20 +241,20 @@ public class TestMath extends TestCase { // Only generate values for 2,3,4 multAdd.generate(2, 5); - assertEquals("MultiplyAdd partial", 0.0, multAdd.output.getValues()[0], 0.001); - assertEquals("MultiplyAdd partial", 0.0, multAdd.output.getValues()[1], 0.001); - assertEquals("MultiplyAdd partial", (x * y) + z, multAdd.output.getValues()[2], 0.001); - assertEquals("MultiplyAdd partial", (x * y) + z, multAdd.output.getValues()[3], 0.001); - assertEquals("MultiplyAdd partial", (x * y) + z, multAdd.output.getValues()[4], 0.001); - assertEquals("MultiplyAdd partial", 0.0, multAdd.output.getValues()[5], 0.001); - assertEquals("MultiplyAdd partial", 0.0, multAdd.output.getValues()[6], 0.001); - assertEquals("MultiplyAdd partial", 0.0, multAdd.output.getValues()[7], 0.001); - + assertEquals(0.0, multAdd.output.getValues()[0], 0.001, "MultiplyAdd partial"); + assertEquals(0.0, multAdd.output.getValues()[1], 0.001, "MultiplyAdd partial"); + assertEquals((x * y) + z, multAdd.output.getValues()[2], 0.001, "MultiplyAdd partial"); + assertEquals((x * y) + z, multAdd.output.getValues()[3], 0.001, "MultiplyAdd partial"); + assertEquals((x * y) + z, multAdd.output.getValues()[4], 0.001, "MultiplyAdd partial"); + assertEquals(0.0, multAdd.output.getValues()[5], 0.001, "MultiplyAdd partial"); + assertEquals(0.0, multAdd.output.getValues()[6], 0.001, "MultiplyAdd partial"); + assertEquals(0.0, multAdd.output.getValues()[7], 0.001, "MultiplyAdd partial"); } /** * Unit test for Compare.java - added by Lisa Tolentino 06/19/2009 */ + @Test public void testCompare() { UnitBinaryOperator compare = new Compare(); compare.setSynthesisEngine(synthesisEngine); @@ -263,9 +266,10 @@ public class TestMath extends TestCase { compare.generate(); - assertEquals("Compare", (x > y ? 1 : 0), compare.output.getValue(), 0.001); + assertEquals((x > y ? 1 : 0), compare.output.getValue(), 0.001, "Compare"); } + @Test public void testPartialCompare() { UnitBinaryOperator compare = new Compare(); compare.setSynthesisEngine(synthesisEngine); @@ -280,20 +284,20 @@ public class TestMath extends TestCase { // Only generate values for 2,3,4 compare.generate(2, 5); - assertEquals("Compare partial", 0.0, compare.output.getValues()[0], 0.001); - assertEquals("Compare partial", 0.0, compare.output.getValues()[1], 0.001); - assertEquals("Compare partial", (x > y ? 1 : 0), compare.output.getValues()[2], 0.001); - assertEquals("Compare partial", (x > y ? 1 : 0), compare.output.getValues()[3], 0.001); - assertEquals("Compare partial", (x > y ? 1 : 0), compare.output.getValues()[4], 0.001); - assertEquals("Compare partial", 0.0, compare.output.getValues()[5], 0.001); - assertEquals("Compare partial", 0.0, compare.output.getValues()[6], 0.001); - assertEquals("Compare partial", 0.0, compare.output.getValues()[7], 0.001); - + assertEquals(0.0, compare.output.getValues()[0], 0.001, "Compare partial"); + assertEquals(0.0, compare.output.getValues()[1], 0.001, "Compare partial"); + assertEquals((x > y ? 1 : 0), compare.output.getValues()[2], 0.001, "Compare partial"); + assertEquals((x > y ? 1 : 0), compare.output.getValues()[3], 0.001, "Compare partial"); + assertEquals((x > y ? 1 : 0), compare.output.getValues()[4], 0.001, "Compare partial"); + assertEquals(0.0, compare.output.getValues()[5], 0.001, "Compare partial"); + assertEquals(0.0, compare.output.getValues()[6], 0.001, "Compare partial"); + assertEquals(0.0, compare.output.getValues()[7], 0.001, "Compare partial"); } /** * Unit test for Maximum.java - added by Lisa Tolentino 06/20/2009 */ + @Test public void testMaximum() { Maximum max = new Maximum(); max.setSynthesisEngine(synthesisEngine); @@ -305,9 +309,10 @@ public class TestMath extends TestCase { max.generate(); - assertEquals("Maximum", (x > y ? x : y), max.output.getValue(), 0.001); + assertEquals((x > y ? x : y), max.output.getValue(), 0.001, "Maximum"); } + @Test public void testPartialMaximum() { Maximum max = new Maximum(); max.setSynthesisEngine(synthesisEngine); @@ -322,20 +327,20 @@ public class TestMath extends TestCase { // Only generate values for 2,3,4 max.generate(2, 5); - assertEquals("Maximum partial", 0.0, max.output.getValues()[0], 0.001); - assertEquals("Maximum partial", 0.0, max.output.getValues()[1], 0.001); - assertEquals("Maximum partial", (x > y ? x : y), max.output.getValues()[2], 0.001); - assertEquals("Maximum partial", (x > y ? x : y), max.output.getValues()[3], 0.001); - assertEquals("Maximum partial", (x > y ? x : y), max.output.getValues()[4], 0.001); - assertEquals("Maximum partial", 0.0, max.output.getValues()[5], 0.001); - assertEquals("Maximum partial", 0.0, max.output.getValues()[6], 0.001); - assertEquals("Maximum partial", 0.0, max.output.getValues()[7], 0.001); - + assertEquals(0.0, max.output.getValues()[0], 0.001, "Maximum partial"); + assertEquals(0.0, max.output.getValues()[1], 0.001, "Maximum partial"); + assertEquals((x > y ? x : y), max.output.getValues()[2], 0.001, "Maximum partial"); + assertEquals((x > y ? x : y), max.output.getValues()[3], 0.001, "Maximum partial"); + assertEquals((x > y ? x : y), max.output.getValues()[4], 0.001, "Maximum partial"); + assertEquals(0.0, max.output.getValues()[5], 0.001, "Maximum partial"); + assertEquals(0.0, max.output.getValues()[6], 0.001, "Maximum partial"); + assertEquals(0.0, max.output.getValues()[7], 0.001, "Maximum partial"); } /** * Unit test for Minimum.java - added by Lisa Tolentino 06/20/2009 */ + @Test public void testMinimum() { Minimum min = new Minimum(); min.setSynthesisEngine(synthesisEngine); @@ -347,9 +352,10 @@ public class TestMath extends TestCase { min.generate(); - assertEquals("Minimum", (x < y ? x : y), min.output.getValue(), 0.001); + assertEquals((x < y ? x : y), min.output.getValue(), 0.001, "Minimum"); } + @Test public void testPartialMinimum() { Minimum min = new Minimum(); min.setSynthesisEngine(synthesisEngine); @@ -364,49 +370,50 @@ public class TestMath extends TestCase { // Only generate values for 2,3,4 min.generate(2, 5); - assertEquals("Maximum partial", 0.0, min.output.getValues()[0], 0.001); - assertEquals("Maximum partial", 0.0, min.output.getValues()[1], 0.001); - assertEquals("Maximum partial", (x < y ? x : y), min.output.getValues()[2], 0.001); - assertEquals("Maximum partial", (x < y ? x : y), min.output.getValues()[3], 0.001); - assertEquals("Maximum partial", (x < y ? x : y), min.output.getValues()[4], 0.001); - assertEquals("Maximum partial", 0.0, min.output.getValues()[5], 0.001); - assertEquals("Maximum partial", 0.0, min.output.getValues()[6], 0.001); - assertEquals("Maximum partial", 0.0, min.output.getValues()[7], 0.001); - + assertEquals(0.0, min.output.getValues()[0], 0.001, "Maximum partial"); + assertEquals(0.0, min.output.getValues()[1], 0.001, "Maximum partial"); + assertEquals((x < y ? x : y), min.output.getValues()[2], 0.001, "Maximum partial"); + assertEquals((x < y ? x : y), min.output.getValues()[3], 0.001, "Maximum partial"); + assertEquals((x < y ? x : y), min.output.getValues()[4], 0.001, "Maximum partial"); + assertEquals(0.0, min.output.getValues()[5], 0.001, "Maximum partial"); + assertEquals(0.0, min.output.getValues()[6], 0.001, "Maximum partial"); + assertEquals(0.0, min.output.getValues()[7], 0.001, "Maximum partial"); } + @Test public void testPowerOfTwo() { PowerOfTwo powerOfTwo = new PowerOfTwo(); powerOfTwo.setSynthesisEngine(synthesisEngine); final double smallValue = -1.5308084989341915E-17; - double values[] = { + double[] values = { 0.0, 1.3, 4.5, -0.5, -1.0, -2.8, smallValue, -smallValue, 1.0 - smallValue, 1.0 + smallValue }; for (double in : values) { powerOfTwo.input.setValueInternal(in); powerOfTwo.generate(); - assertEquals("PowerOfTwo", Math.pow(2.0, in), powerOfTwo.output.getValue(), 0.001); + assertEquals(Math.pow(2.0, in), powerOfTwo.output.getValue(), 0.001, "PowerOfTwo"); } } + + @Test public void testPitchToFrequency() { PitchToFrequency ugen = new PitchToFrequency(); ugen.setSynthesisEngine(synthesisEngine); final double smallValue = -1.5308084989341915E-17; - double values[] = { + double[] values = { 49.0, 49.5, 50.0 + smallValue, 60.0 -smallValue, 79.2, 12.9, 118.973 }; // Sanity check AudioMath - assertEquals("PitchToFrequency", 440.0, AudioMath.pitchToFrequency(69), 0.001); - assertEquals("PitchToFrequency", 660.0, AudioMath.pitchToFrequency(69+7.02), 0.1); + assertEquals(440.0, AudioMath.pitchToFrequency(69), 0.001, "PitchToFrequency"); + assertEquals(660.0, AudioMath.pitchToFrequency(69+7.02), 0.1, "PitchToFrequency"); for (double pitch : values) { ugen.input.setValueInternal(pitch); ugen.generate(); - assertEquals("PitchToFrequency", AudioMath.pitchToFrequency(pitch), - ugen.output.getValue(), 0.001); + assertEquals(ugen.output.getValue(), 0.001, "PitchToFrequency: " + AudioMath.pitchToFrequency(pitch)); } } diff --git a/tests/com/jsyn/unitgen/TestRamps.java b/src/test/java/com/jsyn/unitgen/TestRamps.java index 83ebacf..40d968c 100644 --- a/tests/com/jsyn/unitgen/TestRamps.java +++ b/src/test/java/com/jsyn/unitgen/TestRamps.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,6 +16,10 @@ package com.jsyn.unitgen; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + public class TestRamps extends NonRealTimeTestCase { public void viewContinuousRamp(double duration, double startValue, double targetValue) @@ -59,24 +63,26 @@ public class TestRamps extends NonRealTimeTestCase { synthesisEngine.start(); ramp.start(); synthesisEngine.sleepUntil(synthesisEngine.getCurrentTime() + 0.01); - assertEquals("start flat", ramp.input.getValue(), ramp.output.getValue()); + assertEquals(ramp.input.getValue(), ramp.output.getValue(), "start flat"); ramp.input.set(targetValue); double startTime = synthesisEngine.getCurrentTime(); synthesisEngine.sleepUntil(startTime + (duration / 2)); - assertEquals("ramping up", (targetValue + startValue) / 2.0, ramp.output.getValue(), 0.01); + assertEquals((targetValue + startValue) / 2.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + duration); - assertEquals("ramping up", targetValue, ramp.output.getValue(), 0.01); + assertEquals(targetValue, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + duration + 0.1); - assertEquals("flat again", targetValue, ramp.output.getValue()); + assertEquals(targetValue, ramp.output.getValue(), "flat again"); synthesisEngine.stop(); } + @Test public void testContinuousRamp() throws InterruptedException { viewContinuousRamp(4.0, 0.0, 1.0); } + @Test public void testExponentialRamp() throws InterruptedException { ExponentialRamp ramp = new ExponentialRamp(); synthesisEngine.add(ramp); @@ -89,20 +95,21 @@ public class TestRamps extends NonRealTimeTestCase { synthesisEngine.start(); ramp.start(); synthesisEngine.sleepUntil(synthesisEngine.getCurrentTime() + 0.01); - assertEquals("start flat", ramp.input.getValue(), ramp.output.getValue()); + assertEquals(ramp.input.getValue(), ramp.output.getValue(), "start flat"); ramp.input.set(8.0); double startTime = synthesisEngine.getCurrentTime(); synthesisEngine.sleepUntil(startTime + 0.1); - assertEquals("ramping up", 2.0, ramp.output.getValue(), 0.01); + assertEquals(2.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + 0.2); - assertEquals("ramping up", 4.0, ramp.output.getValue(), 0.01); + assertEquals(4.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + 0.3); - assertEquals("ramping up", 8.0, ramp.output.getValue(), 0.01); + assertEquals(8.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + 0.4); - assertEquals("flat again", 8.0, ramp.output.getValue()); + assertEquals(8.0, ramp.output.getValue(), "flat again"); } + @Test public void testLinearRamp() throws InterruptedException { LinearRamp ramp = new LinearRamp(); synthesisEngine.add(ramp); @@ -115,20 +122,21 @@ public class TestRamps extends NonRealTimeTestCase { synthesisEngine.start(); ramp.start(); synthesisEngine.sleepUntil(synthesisEngine.getCurrentTime() + 0.01); - assertEquals("start flat", ramp.input.getValue(), ramp.output.getValue()); + assertEquals(ramp.input.getValue(), ramp.output.getValue(), "start flat"); ramp.input.set(8.0); double startTime = synthesisEngine.getCurrentTime(); synthesisEngine.sleepUntil(startTime + 0.1); - assertEquals("ramping up", 2.0, ramp.output.getValue(), 0.01); + assertEquals(2.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + 0.2); - assertEquals("ramping up", 4.0, ramp.output.getValue(), 0.01); + assertEquals(4.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + 0.3); - assertEquals("ramping up", 6.0, ramp.output.getValue(), 0.01); + assertEquals(6.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + 0.4); - assertEquals("flat again", 8.0, ramp.output.getValue()); + assertEquals(8.0, ramp.output.getValue(), "flat again"); } + @Test public void testExponentialRampConnected() throws InterruptedException { ExponentialRamp ramp = new ExponentialRamp(); PassThrough pass = new PassThrough(); @@ -147,20 +155,21 @@ public class TestRamps extends NonRealTimeTestCase { synthesisEngine.start(); ramp.start(); synthesisEngine.sleepUntil(synthesisEngine.getCurrentTime() + 0.01); - assertEquals("start flat", ramp.input.getValue(), ramp.output.getValue()); + assertEquals(ramp.input.getValue(), ramp.output.getValue(), "start flat"); pass.input.set(8.0); double startTime = synthesisEngine.getCurrentTime(); synthesisEngine.sleepUntil(startTime + 0.1); - assertEquals("ramping up", 2.0, ramp.output.getValue(), 0.01); + assertEquals(2.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + 0.2); - assertEquals("ramping up", 4.0, ramp.output.getValue(), 0.01); + assertEquals(4.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + 0.3); - assertEquals("ramping up", 8.0, ramp.output.getValue(), 0.01); + assertEquals(8.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + 0.4); - assertEquals("flat again", 8.0, ramp.output.getValue()); + assertEquals(8.0, ramp.output.getValue(), "flat again"); } + @Test public void testLinearRampConnected() throws InterruptedException { LinearRamp ramp = new LinearRamp(); PassThrough pass = new PassThrough(); @@ -179,18 +188,18 @@ public class TestRamps extends NonRealTimeTestCase { synthesisEngine.start(); ramp.start(); synthesisEngine.sleepUntil(synthesisEngine.getCurrentTime() + 0.01); - assertEquals("start flat", ramp.input.getValue(), ramp.output.getValue()); + assertEquals(ramp.input.getValue(), ramp.output.getValue(), "start flat"); pass.input.set(8.0); double startTime = synthesisEngine.getCurrentTime(); synthesisEngine.sleepUntil(startTime + 0.1); - assertEquals("ramping up", 2.0, ramp.output.getValue(), 0.01); + assertEquals(2.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + 0.2); - assertEquals("ramping up", 4.0, ramp.output.getValue(), 0.01); + assertEquals(4.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + 0.3); - assertEquals("ramping up", 6.0, ramp.output.getValue(), 0.01); + assertEquals(6.0, ramp.output.getValue(), 0.01, "ramping up"); synthesisEngine.sleepUntil(startTime + 0.4); - assertEquals("flat again", 8.0, ramp.output.getValue()); + assertEquals(8.0, ramp.output.getValue(), "flat again"); } } diff --git a/tests/com/jsyn/unitgen/TestUnitGate.java b/src/test/java/com/jsyn/unitgen/TestUnitGate.java index 14129aa..cba03e7 100644 --- a/tests/com/jsyn/unitgen/TestUnitGate.java +++ b/src/test/java/com/jsyn/unitgen/TestUnitGate.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,11 +16,12 @@ package com.jsyn.unitgen; -import junit.framework.TestCase; - import com.jsyn.engine.SynthesisEngine; -public class TestUnitGate extends TestCase { +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class TestUnitGate { protected SynthesisEngine synthesisEngine; protected double time; @@ -50,8 +51,8 @@ public class TestUnitGate extends TestCase { time = synthesisEngine.getCurrentTime(); time += 0.1; synthesisEngine.sleepUntil(time); - assertEquals("still idling", 0.0, envelope.output.getValue()); - assertEquals("ramp frozen at beginning", 0.0, ramp.output.getValue(), tolerance); + assertEquals(0.0, envelope.output.getValue(), "still idling"); + assertEquals(0.0, ramp.output.getValue(), tolerance, "ramp frozen at beginning"); // run multiple times to make sure we can retrigger the envelope. for (int i = 0; i < 3; i++) { @@ -61,19 +62,19 @@ public class TestUnitGate extends TestCase { time += 0.1; level += 0.1; synthesisEngine.sleepUntil(time); - assertEquals("ramp going up " + i, level, ramp.output.getValue(), tolerance); - assertTrue("enabled at peak", envelope.isEnabled()); + assertEquals(level, ramp.output.getValue(), tolerance, "ramp going up " + i); + assertTrue(envelope.isEnabled(), "enabled at peak"); envelope.input.off(); time += 0.1; level += 0.1; synthesisEngine.sleepUntil(time); - assertEquals("ramp going up more " + i, level, ramp.output.getValue(), tolerance); - assertEquals("at bottom", 0.0, envelope.output.getValue(), 0.1); + assertEquals(level, ramp.output.getValue(), tolerance, "ramp going up more " + i); + assertEquals(0.0, envelope.output.getValue(), 0.1, "at bottom"); time += 0.2; synthesisEngine.sleepUntil(time); - assertEquals("ramp frozen " + i, level, ramp.output.getValue(), tolerance); + assertEquals(level, ramp.output.getValue(), tolerance, "ramp frozen " + i); } } diff --git a/tests/com/jsyn/util/DebugSampleLoader.java b/src/test/java/com/jsyn/util/DebugSampleLoader.java index 23945b5..c0ddef5 100644 --- a/tests/com/jsyn/util/DebugSampleLoader.java +++ b/src/test/java/com/jsyn/util/DebugSampleLoader.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,13 +26,18 @@ import com.jsyn.unitgen.LineOut; import com.jsyn.unitgen.VariableRateDataReader; import com.jsyn.unitgen.VariableRateMonoReader; import com.jsyn.unitgen.VariableRateStereoReader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Play a sample from a WAV file using JSyn. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public class DebugSampleLoader { + + private static final Logger LOGGER = LoggerFactory.getLogger(DebugSampleLoader.class); + private Synthesizer synth; private VariableRateDataReader samplePlayer; private LineOut lineOut; @@ -75,11 +80,11 @@ public class DebugSampleLoader { // Load the sample and display its properties. SampleLoader.setJavaSoundPreferred(false); sample = SampleLoader.loadFloatSample(sampleFile); - System.out.println("Sample has: channels = " + sample.getChannelsPerFrame()); - System.out.println(" frames = " + sample.getNumFrames()); - System.out.println(" rate = " + sample.getFrameRate()); - System.out.println(" loopStart = " + sample.getSustainBegin()); - System.out.println(" loopEnd = " + sample.getSustainEnd()); + LOGGER.debug("Sample has: channels = " + sample.getChannelsPerFrame()); + LOGGER.debug(" frames = " + sample.getNumFrames()); + LOGGER.debug(" rate = " + sample.getFrameRate()); + LOGGER.debug(" loopStart = " + sample.getSustainBegin()); + LOGGER.debug(" loopEnd = " + sample.getSustainEnd()); if (sample.getChannelsPerFrame() == 1) { synth.add(samplePlayer = new VariableRateMonoReader()); @@ -104,13 +109,13 @@ public class DebugSampleLoader { // We can simply queue the entire file. // Or if it has a loop we can play the loop for a while. if (sample.getSustainBegin() < 0) { - System.out.println("queue the sample"); + LOGGER.debug("queue the sample"); samplePlayer.dataQueue.queue(sample); } else { - System.out.println("queueOn the sample"); + LOGGER.debug("queueOn the sample"); samplePlayer.dataQueue.queueOn(sample); synth.sleepFor(8.0); - System.out.println("queueOff the sample"); + LOGGER.debug("queueOff the sample"); samplePlayer.dataQueue.queueOff(sample); } diff --git a/tests/com/jsyn/util/TestFFT.java b/src/test/java/com/jsyn/util/TestFFT.java index c79157d..5d130c5 100644 --- a/tests/com/jsyn/util/TestFFT.java +++ b/src/test/java/com/jsyn/util/TestFFT.java @@ -16,21 +16,15 @@ package com.jsyn.util; -import junit.framework.TestCase; - import com.softsynth.math.FourierMath; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -public class TestFFT extends TestCase { +import static org.junit.jupiter.api.Assertions.assertEquals; - @Override - protected void setUp() throws Exception { - super.setUp(); - } +public class TestFFT { - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } + private static final Logger LOGGER = LoggerFactory.getLogger(TestFFT.class); public void checkSingleSineDouble(int size, int bin) { double[] ar = new double[size]; @@ -43,9 +37,9 @@ public class TestFFT extends TestCase { FourierMath.transform(1, size, ar, ai); FourierMath.calculateMagnitudes(ar, ai, magnitudes); - assertEquals("magnitude", 0.0, magnitudes[bin-1], 0.000001); - assertEquals("magnitude", amplitude, magnitudes[bin], 0.000001); - assertEquals("magnitude", 0.0, magnitudes[bin+1], 0.000001); + assertEquals(0.0, magnitudes[bin-1], 0.000001, "magnitude"); + assertEquals(amplitude, magnitudes[bin], 0.000001, "magnitude"); + assertEquals(0.0, magnitudes[bin+1], 0.000001, "magnitude"); /* for (int i = 0; i < magnitudes.length; i++) { System.out.printf("%d = %9.7f\n", i, magnitudes[i]); @@ -65,9 +59,9 @@ public class TestFFT extends TestCase { FourierMath.transform(1, size, ar, ai); FourierMath.calculateMagnitudes(ar, ai, magnitudes); - assertEquals("magnitude", 0.0f, magnitudes[bin-1], 0.000001); - assertEquals("magnitude", amplitude, magnitudes[bin], 0.000001); - assertEquals("magnitude", 0.0f, magnitudes[bin+1], 0.000001); + assertEquals(0.0f, magnitudes[bin-1], 0.000001, "magnitude"); + assertEquals(amplitude, magnitudes[bin], 0.000001, "magnitude"); + assertEquals(0.0f, magnitudes[bin+1], 0.000001, "magnitude"); /* for (int i = 0; i < magnitudes.length; i++) { System.out.printf("%d = %9.7f\n", i, magnitudes[i]); @@ -97,7 +91,7 @@ public class TestFFT extends TestCase { break; } } - assertEquals("magnitude", amplitude, magnitudes[bin], 0.000001); + assertEquals(amplitude, magnitudes[bin], 0.000001, "magnitude"); } } diff --git a/tests/com/jsyn/util/TestPseudoRandom.java b/src/test/java/com/jsyn/util/TestPseudoRandom.java index 20df465..b37475f 100644 --- a/tests/com/jsyn/util/TestPseudoRandom.java +++ b/src/test/java/com/jsyn/util/TestPseudoRandom.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,54 +16,48 @@ package com.jsyn.util; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; -public class TestPseudoRandom extends TestCase { +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class TestPseudoRandom { PseudoRandom pseudoRandom; private int[] bins; private final static int BIN_SHIFTER = 8; private final static int BIN_COUNT = 1 << BIN_SHIFTER; private final static int BIN_MASK = BIN_COUNT - 1; - @Override - protected void setUp() throws Exception { - super.setUp(); - pseudoRandom = new PseudoRandom(); - bins = new int[BIN_COUNT]; - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - + @Test public void testMath() { long seed = 3964771111L; int positiveInt = (int) (seed & 0x7FFFFFFF); - assertTrue("masked random positive, " + positiveInt, (positiveInt >= 0)); + assertTrue((positiveInt >= 0), "masked random positive, " + positiveInt); double rand = positiveInt * (1.0 / (1L << 31)); - assertTrue("not too low, " + rand, (rand >= 0.0)); - assertTrue("not too high, " + rand, (rand < 1.0)); + assertTrue((rand >= 0.0), "not too low, " + rand); + assertTrue((rand < 1.0), "not too high, " + rand); } + @Test public void testIntegerDistribution() { int scaler = 100; for (int i = 0; i < (bins.length * scaler); i++) { int rand = pseudoRandom.nextRandomInteger(); int positiveInt = rand & 0x7FFFFFFF; - assertTrue("masked random " + positiveInt, (positiveInt >= 0)); + assertTrue((positiveInt >= 0), "masked random " + positiveInt); int index = (rand >> (32 - BIN_SHIFTER)) & BIN_MASK; bins[index] += 1; } checkDistribution(scaler); } + @Test public void test01Distribution() { int scaler = 100; for (int i = 0; i < (bins.length * scaler); i++) { double rand = pseudoRandom.random(); - assertTrue("not too low, #" + i + " = " + rand, (rand >= 0.0)); - assertTrue("not too high, #" + i + " = " + rand, (rand < 1.0)); + assertTrue((rand >= 0.0), "not too low, #" + i + " = " + rand); + assertTrue((rand < 1.0), "not too high, #" + i + " = " + rand); int index = (int) (rand * BIN_COUNT); bins[index] += 1; } @@ -76,7 +70,7 @@ public class TestPseudoRandom extends TestCase { double coefficient = 0.9; for (int i = 0; i < (bins.length); i++) { average = (average * coefficient) + (bins[i] * (1.0 - coefficient)); - assertEquals("average at " + i, scaler, average, 0.2 * scaler); + assertEquals(scaler, average, 0.2 * scaler, "average at " + i); } } } diff --git a/tests/com/jsyn/util/TestVoiceAllocator.java b/src/test/java/com/jsyn/util/TestVoiceAllocator.java index fd5ba0b..061e2ae 100644 --- a/tests/com/jsyn/util/TestVoiceAllocator.java +++ b/src/test/java/com/jsyn/util/TestVoiceAllocator.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,20 +16,23 @@ package com.jsyn.util; -import junit.framework.TestCase; - import com.jsyn.instruments.SubtractiveSynthVoice; import com.jsyn.unitgen.UnitVoice; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class TestVoiceAllocator extends TestCase { +public class TestVoiceAllocator { VoiceAllocator allocator; int max = 4; - private UnitVoice[] voices; - - @Override - protected void setUp() throws Exception { - super.setUp(); + UnitVoice[] voices; + @BeforeEach + private void beforeEach() { voices = new UnitVoice[max]; for (int i = 0; i < max; i++) { voices[i] = new SubtractiveSynthVoice(); @@ -38,13 +41,9 @@ public class TestVoiceAllocator extends TestCase { allocator = new VoiceAllocator(voices); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - + @Test public void testAllocation() { - assertEquals("get max", max, allocator.getVoiceCount()); + assertEquals(max, allocator.getVoiceCount(), "get max"); int tag1 = 61; int tag2 = 62; @@ -53,33 +52,34 @@ public class TestVoiceAllocator extends TestCase { int tag5 = 65; int tag6 = 66; UnitVoice voice1 = allocator.allocate(tag1); - assertTrue("voice should be non-null", (voice1 != null)); + assertTrue((voice1 != null), "voice should be non-null"); UnitVoice voice2 = allocator.allocate(tag2); - assertTrue("voice should be non-null", (voice2 != null)); - assertTrue("new voice ", (voice2 != voice1)); + assertTrue((voice2 != null), "voice should be non-null"); + assertTrue((voice2 != voice1), "new voice "); UnitVoice voice = allocator.allocate(tag1); - assertTrue("should be voice1 again ", (voice == voice1)); + assertTrue((voice == voice1), "should be voice1 again "); voice = allocator.allocate(tag2); - assertTrue("should be voice2 again ", (voice == voice2)); + assertTrue((voice == voice2), "should be voice2 again "); UnitVoice voice3 = allocator.allocate(tag3); @SuppressWarnings("unused") UnitVoice voice4 = allocator.allocate(tag4); UnitVoice voice5 = allocator.allocate(tag5); - assertTrue("ran out so get voice1 as oldest", (voice5 == voice1)); + assertTrue((voice5 == voice1), "ran out so get voice1 as oldest"); voice = allocator.allocate(tag2); - assertTrue("should be voice2 again ", (voice == voice2)); + assertTrue((voice == voice2), "should be voice2 again "); // Now voice 3 should be the oldest cuz voice 2 was touched. UnitVoice voice6 = allocator.allocate(tag6); - assertTrue("ran out so get voice3 as oldest", (voice6 == voice3)); + assertTrue((voice6 == voice3), "ran out so get voice3 as oldest"); } + @Test public void testOff() { int tag1 = 61; int tag2 = 62; @@ -92,20 +92,20 @@ public class TestVoiceAllocator extends TestCase { UnitVoice voice3 = allocator.allocate(tag3); UnitVoice voice4 = allocator.allocate(tag4); - assertTrue("voice 3 should start on", allocator.isOn(tag3)); + assertTrue(allocator.isOn(tag3), "voice 3 should start on"); allocator.off(tag3); - assertEquals("voice 3 should now be off", false, allocator.isOn(tag3)); + assertFalse(allocator.isOn(tag3), "voice 3 should now be off"); allocator.off(tag2); UnitVoice voice5 = allocator.allocate(tag5); - assertTrue("should get voice3 cuz off first", (voice5 == voice3)); + assertTrue((voice5 == voice3), "should get voice3 cuz off first"); UnitVoice voice6 = allocator.allocate(tag6); - assertTrue("should get voice2 cuz off second", (voice6 == voice2)); + assertTrue((voice6 == voice2), "should get voice2 cuz off second"); voice3 = allocator.allocate(tag3); - assertTrue("should get voice1 cuz on first", (voice3 == voice1)); + assertTrue((voice3 == voice1), "should get voice1 cuz on first"); voice1 = allocator.allocate(tag1); - assertTrue("should get voice4 cuz next up", (voice1 == voice4)); + assertTrue((voice1 == voice4), "should get voice4 cuz next up"); } } diff --git a/tests/com/jsyn/SynthTestSuite.java b/tests/com/jsyn/SynthTestSuite.java deleted file mode 100644 index 958bd4f..0000000 --- a/tests/com/jsyn/SynthTestSuite.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2010 Phil Burk, Mobileer Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.jsyn; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import com.jsyn.data.TestShortSample; -import com.jsyn.engine.TestDevices; -import com.jsyn.engine.TestEngine; -import com.jsyn.engine.TestFifo; -import com.jsyn.engine.TestWaveFileReadWrite; -import com.jsyn.ports.TestQueuedDataPort; -import com.jsyn.ports.TestSet; -import com.jsyn.unitgen.TestEnable; -import com.jsyn.unitgen.TestEnvelopeAttackDecay; -import com.jsyn.unitgen.TestEnvelopeDAHDSR; -import com.jsyn.unitgen.TestFunction; -import com.jsyn.unitgen.TestRamps; -import com.jsyn.util.TestFFT; -import com.jsyn.util.TestVoiceAllocator; - -/** - * Test new pure Java JSyn API. - * - * @author Phil Burk (C) 2010 Mobileer Inc - */ -public class SynthTestSuite { - - public static Test suite() { - - TestSuite suite = new TestSuite(); - - suite.addTestSuite(TestEngine.class); - suite.addTestSuite(TestSet.class); - // suite.addTestSuite( TestMath.class ); - suite.addTestSuite(TestRamps.class); - suite.addTestSuite(TestEnvelopeAttackDecay.class); - suite.addTestSuite(TestEnvelopeDAHDSR.class); - suite.addTestSuite(TestShortSample.class); - suite.addTestSuite(TestDevices.class); - suite.addTestSuite(TestQueuedDataPort.class); - suite.addTestSuite(TestFifo.class); - suite.addTestSuite(TestEnable.class); - suite.addTestSuite(TestFunction.class); - suite.addTestSuite(TestFFT.class); - // suite.addTestSuite( TestSampleLoader.class ); - suite.addTestSuite(TestWaveFileReadWrite.class); - suite.addTestSuite(TestVoiceAllocator.class); - // suite.addTestSuite(TestWrapAroundBug.class); - - return suite; - } - - /** - * Runs the test suite using the textual runner. - */ - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - System.exit(0); - } -} diff --git a/tests/com/jsyn/research/lambdas/LambdaUnits.java b/tests/com/jsyn/research/lambdas/LambdaUnits.java deleted file mode 100644 index 42807ac..0000000 --- a/tests/com/jsyn/research/lambdas/LambdaUnits.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.jsyn.research.lambdas; - -import java.util.function.BinaryOperator; - -public class LambdaUnits { - - - public static void main(String[] args) { - test(); - } - - void tryLambda(BinaryOperator<Double> op) { - double result = op.apply(3.0, 4.0); - System.out.println("result = " + result); - } - - private static void test() { - System.out.println("Test Lambdas"); - // Need Java 8! tryLambda((x, y) -> (x * y)); - } - -} |