diff options
Diffstat (limited to 'src/main/java/com')
18 files changed, 70 insertions, 234 deletions
diff --git a/src/main/java/com/jsyn/apps/InstrumentTester.java b/src/main/java/com/jsyn/apps/InstrumentTester.java index 2505759..ec3ce98 100644 --- a/src/main/java/com/jsyn/apps/InstrumentTester.java +++ b/src/main/java/com/jsyn/apps/InstrumentTester.java @@ -41,8 +41,6 @@ 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 @@ -52,8 +50,6 @@ import org.slf4j.LoggerFactory; * @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; @@ -110,10 +106,10 @@ public class InstrumentTester extends JApplet { // Put the receiver in the transmitter. // This gives fairly low latency playing. keyboard.getTransmitter().setReceiver(receiver); - LOGGER.debug("Play MIDI keyboard: " + keyboard.getDeviceInfo().getDescription()); + System.out.println("Play MIDI keyboard: " + keyboard.getDeviceInfo().getDescription()); result = 0; } else { - LOGGER.debug("Could not find a keyboard."); + System.out.println("Could not find a keyboard."); } return result; } diff --git a/src/main/java/com/jsyn/devices/javasound/JavaSoundAudioDevice.java b/src/main/java/com/jsyn/devices/javasound/JavaSoundAudioDevice.java index 75c4a8a..1a63b32 100644 --- a/src/main/java/com/jsyn/devices/javasound/JavaSoundAudioDevice.java +++ b/src/main/java/com/jsyn/devices/javasound/JavaSoundAudioDevice.java @@ -30,8 +30,6 @@ 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. @@ -40,8 +38,6 @@ import org.slf4j.LoggerFactory; */ 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; @@ -55,17 +51,15 @@ public class JavaSoundAudioDevice implements AudioDeviceManager { String osName = System.getProperty("os.name"); if (osName.contains("Windows")) { suggestedOutputLatency = 0.08; - LOGGER.info("JSyn: default output latency set to " - + ((int) (suggestedOutputLatency * 1000)) + " msec for " + osName); } deviceRecords = new ArrayList<DeviceInfo>(); sniffAvailableMixers(); - dumpAvailableMixers(); + if (false) dumpAvailableMixers(); } private void dumpAvailableMixers() { for (DeviceInfo deviceInfo : deviceRecords) { - LOGGER.debug("" + deviceInfo); + System.out.println("" + deviceInfo); } } @@ -177,14 +171,12 @@ public class JavaSoundAudioDevice implements AudioDeviceManager { public void start() { DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); if (!AudioSystem.isLineSupported(info)) { - // Handle the error. - LOGGER.error("JavaSoundOutputStream - not supported." + format); + // TODO Handle the error. } else { try { line = (SourceDataLine) getDataLine(info); int bufferSize = calculateBufferSize(suggestedOutputLatency); line.open(format, bufferSize); - LOGGER.debug("Output buffer size = " + bufferSize + " bytes."); line.start(); } catch (Exception e) { @@ -273,14 +265,12 @@ public class JavaSoundAudioDevice implements AudioDeviceManager { public void start() { DataLine.Info info = new DataLine.Info(TargetDataLine.class, format); if (!AudioSystem.isLineSupported(info)) { - // Handle the error. - LOGGER.error("JavaSoundInputStream - not supported." + format); + // TODO Handle the error. } else { try { line = (TargetDataLine) getDataLine(info); int bufferSize = calculateBufferSize(suggestedInputLatency); line.open(format, bufferSize); - LOGGER.debug("Input buffer size = " + bufferSize + " bytes."); line.start(); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/com/jsyn/devices/javasound/MidiDeviceTools.java b/src/main/java/com/jsyn/devices/javasound/MidiDeviceTools.java index 9cff095..a7a7528 100644 --- a/src/main/java/com/jsyn/devices/javasound/MidiDeviceTools.java +++ b/src/main/java/com/jsyn/devices/javasound/MidiDeviceTools.java @@ -16,8 +16,6 @@ package com.jsyn.devices.javasound; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.sound.midi.MidiDevice; import javax.sound.midi.MidiSystem; @@ -27,20 +25,18 @@ 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) { - LOGGER.debug("MIDI Info: " + info.getDescription() + ", " + info.getName() + ", " + System.out.println("MIDI Info: " + info.getDescription() + ", " + info.getName() + ", " + info.getVendor() + ", " + info.getVersion()); // Get the device for more information. try { MidiDevice device = MidiSystem.getMidiDevice(info); - LOGGER.debug(" Device: " + ", #recv = " + device.getMaxReceivers() + System.out.println(" Device: " + ", #recv = " + device.getMaxReceivers() + ", #xmit = " + device.getMaxTransmitters() + ", open = " + device.isOpen() + ", " + device); } catch (MidiUnavailableException e) { @@ -67,7 +63,7 @@ public class MidiDeviceTools { || (info.getDescription().toLowerCase() .contains(text.toLowerCase()))) { keyboard = device; - LOGGER.debug("Chose: " + info.getDescription()); + System.out.println("Chose: " + info.getDescription()); break; } } diff --git a/src/main/java/com/jsyn/devices/jportaudio/JPortAudioDevice.java b/src/main/java/com/jsyn/devices/jportaudio/JPortAudioDevice.java index 15ab9ed..4c8d4fc 100644 --- a/src/main/java/com/jsyn/devices/jportaudio/JPortAudioDevice.java +++ b/src/main/java/com/jsyn/devices/jportaudio/JPortAudioDevice.java @@ -24,13 +24,9 @@ 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; @@ -165,7 +161,6 @@ public class JPortAudioDevice implements AudioDeviceManager { streamParameters.device = deviceID; streamParameters.suggestedLatency = suggestedOutputLatency; int flags = 0; - LOGGER.debug("Audio output on " + getDeviceName(deviceID)); blockingStream = PortAudio.openStream(null, streamParameters, frameRate, FRAMES_PER_BUFFER, flags); } @@ -213,7 +208,6 @@ public class JPortAudioDevice implements AudioDeviceManager { streamParameters.device = deviceID; streamParameters.suggestedLatency = suggestedInputLatency; int flags = 0; - LOGGER.debug("Audio input from " + getDeviceName(deviceID)); blockingStream = PortAudio.openStream(streamParameters, null, frameRate, FRAMES_PER_BUFFER, flags); } diff --git a/src/main/java/com/jsyn/engine/SynthesisEngine.java b/src/main/java/com/jsyn/engine/SynthesisEngine.java index 30872a8..34fffbe 100644 --- a/src/main/java/com/jsyn/engine/SynthesisEngine.java +++ b/src/main/java/com/jsyn/engine/SynthesisEngine.java @@ -16,6 +16,7 @@ package com.jsyn.engine; +import java.util.logging.Logger; import java.util.ArrayList; import java.util.List; import java.util.ListIterator; @@ -31,8 +32,6 @@ 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 @@ -55,8 +54,6 @@ import org.slf4j.LoggerFactory; */ 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. @@ -96,6 +93,8 @@ 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; } @@ -217,7 +216,6 @@ 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."); return; } @@ -226,7 +224,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; @@ -234,11 +232,11 @@ public class SynthesisEngine implements Synthesizer { if (useRealTime) { engineThread = new EngineThread(inputDeviceID, numInputChannels, outputDeviceID, numOutputChannels); - LOGGER.debug("Synth thread old priority = " + engineThread.getPriority()); + logger.fine("Synth thread old priority = " + engineThread.getPriority()); int engineThreadPriority = engineThread.getPriority() + 2 > Thread.MAX_PRIORITY ? Thread.MAX_PRIORITY : engineThread.getPriority() + 2; engineThread.setPriority(engineThreadPriority); - LOGGER.debug("Synth thread new priority = " + engineThread.getPriority()); + logger.fine("Synth thread new priority = " + engineThread.getPriority()); engineThread.start(); } @@ -254,7 +252,7 @@ public class SynthesisEngine implements Synthesizer { @Override public synchronized void stop() { if (!started) { - LOGGER.info("JSyn already stopped."); + logger.info("JSyn already stopped."); return; } @@ -301,23 +299,23 @@ public class SynthesisEngine implements Synthesizer { @Override public void run() { - LOGGER.debug("JSyn synthesis thread starting."); + logger.fine("JSyn synthesis thread starting."); try { if (audioInputStream != null) { - LOGGER.debug("JSyn synthesis thread trying to start audio INPUT!"); + logger.fine("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.debug(msg); + logger.fine(msg); } if (audioOutputStream != null) { - LOGGER.debug("JSyn synthesis thread trying to start audio OUTPUT!"); + logger.fine("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.debug(msg); + logger.fine(msg); // Buy some time while we fill the buffer. audioOutputStream.write(outputBuffer.interleavedBuffer); } @@ -350,7 +348,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(); @@ -359,7 +357,7 @@ public class SynthesisEngine implements Synthesizer { audioOutputStream.stop(); } } - LOGGER.debug("JSyn synthesis thread exiting."); + logger.fine("JSyn synthesis thread exiting."); } } @@ -408,7 +406,7 @@ public class SynthesisEngine implements Synthesizer { while (timeList != null) { while (!timeList.isEmpty()) { ScheduledCommand command = timeList.remove(0); - LOGGER.debug("processing " + command + ", at time " + timeStamp.getTime()); + logger.fine("processing " + command + ", at time " + timeStamp.getTime()); command.run(); } // Get next list of commands at the given time. @@ -421,7 +419,7 @@ public class SynthesisEngine implements Synthesizer { if ((Thread.currentThread() == engineThread) && (timeStamp.getTime() <= getCurrentTime())) { command.run(); } else { - LOGGER.debug("scheduling " + command + ", at time " + timeStamp.getTime()); + logger.fine("scheduling " + command + ", at time " + timeStamp.getTime()); commandQueue.add(timeStamp, command); } } @@ -541,7 +539,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) { @@ -552,7 +550,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/main/java/com/jsyn/midi/MidiSynthesizer.java b/src/main/java/com/jsyn/midi/MidiSynthesizer.java index e5dbae7..1f5485c 100644 --- a/src/main/java/com/jsyn/midi/MidiSynthesizer.java +++ b/src/main/java/com/jsyn/midi/MidiSynthesizer.java @@ -17,8 +17,6 @@ package com.jsyn.midi; import com.jsyn.util.MultiChannelSynthesizer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Map MIDI messages into calls to a MultiChannelSynthesizer. @@ -41,7 +39,6 @@ import org.slf4j.LoggerFactory; */ public class MidiSynthesizer extends MessageParser { - private static final Logger LOGGER = LoggerFactory.getLogger(MidiSynthesizer.class); private MultiChannelSynthesizer multiSynth; @@ -56,7 +53,6 @@ public class MidiSynthesizer extends MessageParser { switch (index) { case MidiConstants.CONTROLLER_MOD_WHEEL: double vibratoDepth = 0.1 * normalized; - LOGGER.debug( "vibratoDepth = " + vibratoDepth ); multiSynth.setVibratoDepth(channel, vibratoDepth); break; case MidiConstants.CONTROLLER_TIMBRE: diff --git a/src/main/java/com/jsyn/ports/PortBlockPart.java b/src/main/java/com/jsyn/ports/PortBlockPart.java index b1ced32..1b52d59 100644 --- a/src/main/java/com/jsyn/ports/PortBlockPart.java +++ b/src/main/java/com/jsyn/ports/PortBlockPart.java @@ -22,8 +22,6 @@ 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. @@ -32,8 +30,6 @@ import org.slf4j.LoggerFactory; */ 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; @@ -66,19 +62,12 @@ public class PortBlockPart implements ConnectableOutput, ConnectableInput { } private void addConnection(PortBlockPart otherPart) { - // LOGGER.debug("addConnection from " + this + " to " + otherPart - // ); - if (connections.contains(otherPart)) { - LOGGER.debug("addConnection already had connection from " + this + " to " - + otherPart); - } else { + if (!connections.contains(otherPart)) { connections.add(otherPart); } } private void removeConnection(PortBlockPart otherPart) { - // LOGGER.debug("removeConnection from " + this + " to " + - // otherPart ); connections.remove(otherPart); } diff --git a/src/main/java/com/jsyn/scope/swing/ScopeProbePanel.java b/src/main/java/com/jsyn/scope/swing/ScopeProbePanel.java index a0dec91..45794cd 100644 --- a/src/main/java/com/jsyn/scope/swing/ScopeProbePanel.java +++ b/src/main/java/com/jsyn/scope/swing/ScopeProbePanel.java @@ -29,12 +29,9 @@ 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; @@ -70,7 +67,6 @@ public class ScopeProbePanel extends JPanel { public void actionPerformed(ActionEvent e) { ToggleButtonModel model = (ToggleButtonModel) e.getSource(); boolean enabled = !model.isSelected(); - LOGGER.debug("Knob enabled = " + enabled); verticalScaleKnob.setEnabled(!model.isSelected()); } }); diff --git a/src/main/java/com/jsyn/swing/ASCIIMusicKeyboard.java b/src/main/java/com/jsyn/swing/ASCIIMusicKeyboard.java index dc02259..f92fc1a 100644 --- a/src/main/java/com/jsyn/swing/ASCIIMusicKeyboard.java +++ b/src/main/java/com/jsyn/swing/ASCIIMusicKeyboard.java @@ -16,9 +16,6 @@ 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; @@ -39,8 +36,6 @@ 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"; @@ -69,7 +64,6 @@ public abstract class ASCIIMusicKeyboard extends JPanel { public void keyPressed(KeyEvent e) { int key = e.getKeyChar(); int idx = keyboardLayout.indexOf(key); - LOGGER.debug("keyPressed " + idx); if (idx >= 0) { if (!pressedKeys.contains(idx)) { keyOn(convertIndexToPitch(idx)); @@ -86,7 +80,6 @@ public abstract class ASCIIMusicKeyboard extends JPanel { public void keyReleased(KeyEvent e) { int key = e.getKeyChar(); int idx = keyboardLayout.indexOf(key); - LOGGER.debug("keyReleased " + idx); if (idx >= 0) { if (!sustainBox.isSelected()) { noteOffInternal(idx); diff --git a/src/main/java/com/jsyn/swing/ExponentialRangeModel.java b/src/main/java/com/jsyn/swing/ExponentialRangeModel.java index c807000..1ecb05e 100644 --- a/src/main/java/com/jsyn/swing/ExponentialRangeModel.java +++ b/src/main/java/com/jsyn/swing/ExponentialRangeModel.java @@ -16,9 +16,6 @@ package com.jsyn.swing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * Maps integer range info to a double value along an exponential scale. * @@ -40,7 +37,6 @@ import org.slf4j.LoggerFactory; */ public class ExponentialRangeModel extends DoubleBoundedRangeModel { - private static final Logger LOGGER = LoggerFactory.getLogger(ExponentialRangeModel.class); private static final long serialVersionUID = -142785624892302160L; double a = 1.0; @@ -104,7 +100,6 @@ public class ExponentialRangeModel extends DoubleBoundedRangeModel { public void test(int sliderValue) { double dval = sliderToDouble(sliderValue); int ival = doubleToSlider(dval); - LOGGER.debug(sliderValue + " => " + dval + " => " + ival); } } diff --git a/src/main/java/com/jsyn/unitgen/PitchDetector.java b/src/main/java/com/jsyn/unitgen/PitchDetector.java index ff44c93..9772ff6 100644 --- a/src/main/java/com/jsyn/unitgen/PitchDetector.java +++ b/src/main/java/com/jsyn/unitgen/PitchDetector.java @@ -20,8 +20,6 @@ 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 @@ -35,7 +33,6 @@ import org.slf4j.LoggerFactory; */ public class PitchDetector extends UnitGenerator { - private static final Logger LOGGER = LoggerFactory.getLogger(PitchDetector.class); public UnitInputPort input; @@ -81,10 +78,7 @@ public class PitchDetector extends UnitGenerator { for (int i = start; i < limit; i++) { double current = inputs[i]; if (signalCorrelator.addSample(current)) { - lastPeriod = signalCorrelator.getPeriod(); - if (lastPeriod < 0.1) { - LOGGER.debug("ILLEGAL PERIOD"); - } + lastPeriod = Math.max(0.1, signalCorrelator.getPeriod()); double currentFrequency = getFrameRate() / (lastPeriod + 0); double confidence = signalCorrelator.getConfidence(); if (confidence > 0.1) { diff --git a/src/main/java/com/jsyn/unitgen/UnitGenerator.java b/src/main/java/com/jsyn/unitgen/UnitGenerator.java index 7aacaf1..665b7b1 100644 --- a/src/main/java/com/jsyn/unitgen/UnitGenerator.java +++ b/src/main/java/com/jsyn/unitgen/UnitGenerator.java @@ -27,8 +27,6 @@ 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. @@ -37,8 +35,6 @@ import org.slf4j.LoggerFactory; */ 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. @@ -147,7 +143,6 @@ public abstract class UnitGenerator { while (unit.circuit != null) { unit = unit.circuit; } - LOGGER.debug("getTopUnit " + this + " => " + unit); return unit; } @@ -331,9 +326,7 @@ public abstract class UnitGenerator { public void setPort(String portName, double value, TimeStamp timeStamp) { UnitInputPort port = (UnitInputPort) getPortByName(portName); // LOGGER.debug("setPort " + port ); - if (port == null) { - LOGGER.warn("port was null for name " + portName + ", " + this.getClass().getName()); - } else { + if (port != null) { port.set(value, timeStamp); } } diff --git a/src/main/java/com/jsyn/util/JavaTools.java b/src/main/java/com/jsyn/util/JavaTools.java index 570e4c4..3b4580b 100644 --- a/src/main/java/com/jsyn/util/JavaTools.java +++ b/src/main/java/com/jsyn/util/JavaTools.java @@ -16,29 +16,20 @@ 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; try { newClass = Class.forName(className); - } catch (Throwable e) { - if (verbose) - LOGGER.debug("Caught " + e); - } - if (newClass == null) { + } catch (Throwable e1) { try { ClassLoader systemLoader = ClassLoader.getSystemClassLoader(); newClass = Class.forName(className, true, systemLoader); - } catch (Throwable e) { + } catch (Throwable e2) { if (verbose) - LOGGER.debug("Caught " + e); + System.err.println("Caught " + e2); } } return newClass; diff --git a/src/main/java/com/jsyn/util/NumericOutput.java b/src/main/java/com/jsyn/util/NumericOutput.java index e30975f..d00a9e5 100644 --- a/src/main/java/com/jsyn/util/NumericOutput.java +++ b/src/main/java/com/jsyn/util/NumericOutput.java @@ -16,9 +16,6 @@ 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. @@ -28,8 +25,6 @@ import org.slf4j.LoggerFactory; 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); @@ -54,9 +49,9 @@ public class NumericOutput { boolean ifNeg = false; // only do sign if decimal if (radix != 10) { - // LOGGER.debug("MASK before : ln = " + ln ); + // System.out.println("MASK before : ln = " + ln ); ln = ln & 0x00000000FFFFFFFFL; - // LOGGER.debug("MASK after : ln = " + ln ); + // System.out.println("MASK after : ln = " + ln ); } else if (ln < 0) { ifNeg = true; ln = -ln; @@ -64,7 +59,7 @@ public class NumericOutput { if (ln == 0) { buf.append('0'); } else { - // LOGGER.debug(" ln = " + ln ); + // System.out.println(" ln = " + ln ); while (ln > 0) { int rem = (int) (ln % radix); buf.append(digitToChar(rem)); @@ -147,34 +142,34 @@ public class NumericOutput { } static void testInteger(int n) { - LOGGER.debug("Test " + n + ", 0x" + Integer.toHexString(n) + ", %" + System.out.println("Test " + n + ", 0x" + Integer.toHexString(n) + ", %" + Integer.toBinaryString(n)); - 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)); + 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)); } static void testDouble(double value) { - LOGGER.debug("Test " + value); - LOGGER.debug(" +,5,1 = " + doubleToString(value, 5, 1)); - LOGGER.debug(" -,5,1 = " + doubleToString(-value, 5, 1)); + 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(" +,14,3 = " + doubleToString(value, 14, 3)); - LOGGER.debug(" -,14,3 = " + doubleToString(-value, 14, 3)); + System.out.println(" +,14,3 = " + doubleToString(value, 14, 3)); + System.out.println(" -,14,3 = " + doubleToString(-value, 14, 3)); - LOGGER.debug(" +,6,2,true = " + doubleToString(value, 6, 2, true)); - LOGGER.debug(" -,6,2,true = " + doubleToString(-value, 6, 2, true)); + System.out.println(" +,6,2,true = " + doubleToString(value, 6, 2, true)); + System.out.println(" -,6,2,true = " + doubleToString(-value, 6, 2, true)); } public static void main(String argv[]) { - LOGGER.debug("Test NumericOutput"); + System.out.println("Test NumericOutput"); testInteger(0); testInteger(1); testInteger(16); diff --git a/src/main/java/com/jsyn/util/soundfile/AIFFFileParser.java b/src/main/java/com/jsyn/util/soundfile/AIFFFileParser.java index 89b443c..3126599 100644 --- a/src/main/java/com/jsyn/util/soundfile/AIFFFileParser.java +++ b/src/main/java/com/jsyn/util/soundfile/AIFFFileParser.java @@ -22,13 +22,9 @@ 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'; @@ -166,8 +162,6 @@ public class AIFFFileParser extends AudioFileParser { // are at end. long numInMark = parser.getOffset() - startOffset; if (numInMark >= ckSize) { - LOGGER.debug("Reached end of MARK chunk with bogus numCuePoints = " - + numCuePoints); break; } @@ -182,10 +176,6 @@ public class AIFFFileParser extends AudioFileParser { SampleMarker cuePoint = findOrCreateCuePoint(uniqueID); cuePoint.position = position; cuePoint.name = markerName; - - if (IFFParser.debug) { - LOGGER.debug("AIFF Marker at " + position + ", " + markerName); - } } } diff --git a/src/main/java/com/jsyn/util/soundfile/IFFParser.java b/src/main/java/com/jsyn/util/soundfile/IFFParser.java index 9bb4ec3..dc6acea 100644 --- a/src/main/java/com/jsyn/util/soundfile/IFFParser.java +++ b/src/main/java/com/jsyn/util/soundfile/IFFParser.java @@ -16,9 +16,6 @@ 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; @@ -37,8 +34,6 @@ import java.io.InputStream; class IFFParser extends FilterInputStream { - private static final Logger LOGGER = LoggerFactory.getLogger(IFFParser.class); - private long numBytesRead = 0; private long totalSize = 0; private int fileId; @@ -197,8 +192,6 @@ class IFFParser extends FilterInputStream { int numBytes = readChunkSize(); totalSize = numBytes + 8; parseChunk(handler, fileId, numBytes); - if (debug) - LOGGER.debug("parse() ------- end"); } /** @@ -206,16 +199,10 @@ class IFFParser extends FilterInputStream { * after the type field. */ void parseForm(ChunkHandler handler, int ID, int numBytes, int type) throws IOException { - if (debug) { - LOGGER.debug("IFF: parseForm >>>>>>>>>>>>>>>>>> BEGIN"); - } while (numBytes > 8) { int ckid = readIntBig(); int size = readChunkSize(); numBytes -= 8; - if (debug) { - LOGGER.debug("chunk( " + IDToString(ckid) + ", " + size + " )"); - } if (size < 0) { throw new IOException("Bad IFF chunk Size: " + IDToString(ckid) + " = 0x" + Integer.toHexString(ckid) + ", Size = " + size); @@ -224,17 +211,9 @@ class IFFParser extends FilterInputStream { if ((size & 1) == 1) size++; // even-up numBytes -= size; - if (debug) { - LOGGER.debug("parseForm: numBytes left in form = " + numBytes); - } - } - if (debug) { - LOGGER.debug("IFF: parseForm <<<<<<<<<<<<<<<<<<<< END"); } if (numBytes > 0) { - LOGGER.debug("IFF Parser detected " + numBytes - + " bytes of garbage at end of FORM."); skip(numBytes); } } @@ -249,9 +228,6 @@ class IFFParser extends FilterInputStream { startOffset = getOffset(); if (isForm(ckid)) { int type = readIntBig(); - if (debug) - LOGGER.debug("parseChunk: form = " + IDToString(ckid) + ", " + numBytes - + ", " + IDToString(type)); handler.handleForm(this, ckid, numBytes - 4, type); endOffset = getOffset(); numRead = (int) (endOffset - startOffset); @@ -262,10 +238,6 @@ class IFFParser extends FilterInputStream { } endOffset = getOffset(); numRead = (int) (endOffset - startOffset); - if (debug) { - LOGGER.debug("parseChunk: endOffset = " + endOffset); - LOGGER.debug("parseChunk: numRead = " + numRead); - } if ((numBytes & 1) == 1) numBytes++; // even-up if (numRead < numBytes) @@ -273,8 +245,6 @@ class IFFParser extends FilterInputStream { } public void readHead() throws IOException { - if (debug) - LOGGER.debug("parse() ------- begin"); numBytesRead = 0; fileId = readIntBig(); } diff --git a/src/main/java/com/jsyn/util/soundfile/WAVEFileParser.java b/src/main/java/com/jsyn/util/soundfile/WAVEFileParser.java index a083961..30e3d55 100644 --- a/src/main/java/com/jsyn/util/soundfile/WAVEFileParser.java +++ b/src/main/java/com/jsyn/util/soundfile/WAVEFileParser.java @@ -22,13 +22,9 @@ 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; @@ -94,9 +90,6 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { /* Parse various chunks encountered in WAV file. */ void parseCueChunk(IFFParser parser, int ckSize) throws IOException { int numCuePoints = parser.readIntLittle(); - if (IFFParser.debug) { - LOGGER.debug("WAV: numCuePoints = " + numCuePoints); - } if ((ckSize - 4) != (6 * 4 * numCuePoints)) throw new EOFException("Cue chunk too short!"); for (int i = 0; i < numCuePoints; i++) { @@ -104,11 +97,6 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { int position = parser.readIntLittle(); // dwPosition parser.skip(3 * 4); // fccChunk, dwChunkStart, dwBlockStart int sampleOffset = parser.readIntLittle(); // dwPosition - - if (IFFParser.debug) { - LOGGER.debug("WAV: parseCueChunk: #" + i + ", dwPosition = " + position - + ", dwName = " + dwName + ", dwSampleOffset = " + sampleOffset); - } SampleMarker cuePoint = findOrCreateCuePoint(dwName); cuePoint.position = position; } @@ -118,9 +106,6 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { int dwName = parser.readIntLittle(); int textLength = (ckSize - 4) - 1; // don't read NUL terminator String text = parseString(parser, textLength); - if (IFFParser.debug) { - LOGGER.debug("WAV: label id = " + dwName + ", text = " + text); - } SampleMarker cuePoint = findOrCreateCuePoint(dwName); cuePoint.name = text; } @@ -133,10 +118,6 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { // terminator if (textLength > 0) { String text = parseString(parser, textLength); - if (IFFParser.debug) { - LOGGER.debug("WAV: ltxt id = " + dwName + ", dwSampleLength = " - + dwSampleLength + ", text = " + text); - } SampleMarker cuePoint = findOrCreateCuePoint(dwName); cuePoint.comment = text; } @@ -149,12 +130,6 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { parser.readIntLittle(); /* skip dwAvgBytesPerSec */ blockAlign = parser.readShortLittle(); bitsPerSample = parser.readShortLittle(); - - if (IFFParser.debug) { - LOGGER.debug("WAV: format = 0x" + Integer.toHexString(format)); - LOGGER.debug("WAV: bitsPerSample = " + bitsPerSample); - LOGGER.debug("WAV: samplesPerFrame = " + samplesPerFrame); - } bytesPerFrame = blockAlign; bytesPerSample = bytesPerFrame / samplesPerFrame; samplesPerBlock = (8 * blockAlign) / bitsPerSample; @@ -165,16 +140,6 @@ class WAVEFileParser extends AudioFileParser implements ChunkHandler { int channelMask = parser.readIntLittle(); byte[] guid = new byte[16]; parser.read(guid); - if (IFFParser.debug) { - 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] + ", "); - } - LOGGER.debug("}"); - } if (matchBytes(guid, KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) { format = WAVE_FORMAT_IEEE_FLOAT; } else if (matchBytes(guid, KSDATAFORMAT_SUBTYPE_PCM)) { diff --git a/src/main/java/com/softsynth/math/Polynomial.java b/src/main/java/com/softsynth/math/Polynomial.java index 6c6f96a..d6723c2 100644 --- a/src/main/java/com/softsynth/math/Polynomial.java +++ b/src/main/java/com/softsynth/math/Polynomial.java @@ -16,9 +16,6 @@ package com.softsynth.math; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.Vector; /** @@ -32,8 +29,6 @@ import java.util.Vector; public class Polynomial { - private static final Logger LOGGER = LoggerFactory.getLogger(Polynomial.class); - private final Vector terms; // TODO: Does this need to exist? @@ -225,34 +220,34 @@ public class Polynomial { public static void main(String[] args) { Polynomial p1 = new Polynomial(); - LOGGER.debug("p1=" + p1); + System.out.println("p1=" + p1); Polynomial p2 = new Polynomial(3); - LOGGER.debug("p2=" + p2); + System.out.println("p2=" + p2); Polynomial p3 = new Polynomial(2, 3); - LOGGER.debug("p3=" + p3); + System.out.println("p3=" + p3); Polynomial p4 = new Polynomial(1, 2, 3); - LOGGER.debug("p4=" + p4); - LOGGER.debug("p4*5=" + Polynomial.mult(5.0, p4)); + System.out.println("p4=" + p4); + System.out.println("p4*5=" + Polynomial.mult(5.0, p4)); - LOGGER.debug("{}", p4.evaluate(10)); + System.out.println(p4.evaluate(10)); - LOGGER.debug("{}", Polynomial.plus(p4, p1)); - LOGGER.debug("{}", Polynomial.minus(p4, p3)); + System.out.println(Polynomial.plus(p4, p1)); + System.out.println(Polynomial.minus(p4, p3)); p4.setTerm(12.2, 5); - LOGGER.debug("{}", p4); + System.out.println(p4); p4.addTerm(0.8, 5); - LOGGER.debug("{}", p4); + System.out.println(p4); p4.addTerm(0.8, 7); - LOGGER.debug("{}", p4); - LOGGER.debug("{}", Polynomial.mult(p3, p2)); - LOGGER.debug("{}", Polynomial.mult(p3, p3)); - LOGGER.debug("{}", Polynomial.mult(p2, p2)); + 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)); 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); - LOGGER.debug(t2 + "\n" + t3 + "\n" + t4); + System.out.println(t2 + "\n" + t3 + "\n" + t4); // com.softsynth.jmsl.util } |