music.columbia.edu - JSyn mailing list wrote:
Hi
I have tried a number of different routes, is it something specific to ASIO or the WMME dll's? I have been using the ChannelOut for some time.
Here something I wrote to test it :
import java.io.IOException;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import com.softsynth.jsyn.AudioDevice;
import com.softsynth.jsyn.ChannelOut;
import com.softsynth.jsyn.SineOscillator;
import com.softsynth.jsyn.Synth;
import com.softsynth.jsyn.SynthContext;
public class Engine implements Runnable
{
private Logger logger = Logger.getLogger(getClass());
private SynthContext context;
// Global server running flag
private boolean synth_engine_running = false;
protected SynthContext getSynthContext()
{
return context;
}
/**
*
*/
public void run()
{
PropertyConfigurator.configure("logger.properties");
initialize();
while (synth_engine_running)
{
serverWait();
}
}
/**
* Wait for activity on the server.
*/
private synchronized void serverWait()
{
try
{
wait();
} catch (InterruptedException e)
{
logger.debug("Thread Interupted : " + e.getMessage());
}
}
/**
* Initialize the audio device configured.
*/
private void initialize()
{
logger.info(Synth.getVersion());
context = new SynthContext();
context.setTrace(Synth.TERSE);
// Output the devices for configuration purposes.
printDevices();
// The context must be initialized otherwise the VM crashes.
context.initialize();
// Start the context instance, if successful flag the server as running.
context.start(Synth.FLAG_ENABLE_INPUT, 192000, AudioDevice.getDefaultInputDeviceID(), 1, AudioDevice
.getDefaultOutputDeviceID(), AudioDevice.getMaxOutputChannels(AudioDevice.getDefaultOutputDeviceID()));
//
synth_engine_running = true;
}
public boolean isEngineRunning()
{
return synth_engine_running;
}
/**
* Output a list of devices available on this system.
*/
private void printDevices()
{
for (int i = 0; i < AudioDevice.getNumDevices(); i++)
{
logger.info(i + " : " + AudioDevice.getName(i) + " / Input=" + AudioDevice.getMaxInputChannels(i) + " / Output="
+ AudioDevice.getMaxOutputChannels(i));
}
}
public static void main(String[] args) throws UnsupportedAudioFileException, IOException, InterruptedException
{
int tick;
Engine engine = new Engine();
Thread engine_thread = new Thread(engine, "Audio Engine Thread");
engine_thread.start();
while (!engine.isEngineRunning())
{
Thread.sleep(100);
}
ChannelOut out = new ChannelOut(engine.getSynthContext(), 3);
SineOscillator sine = new SineOscillator(engine.getSynthContext());
tick = engine.getTickStartTime_100ms();
sine.output.connect(out.input);
sine.frequency.set(1000);
out.start(tick);
sine.start(tick);
}
public int getTickStartTime_100ms()
{
return (int) (context.getTickCount() + (0.1d * context.getTickRate()));
}
}
It plays fine on the first 2 channels after that it doesn't play. I have tried this on a normal PCI Audigy card and a USB Sound Blaster Audigy 2 NX
Regards
James