pe.setSource(SYNC.i, sync, OUT.i);
pe.setSource(SYNCPHASE.i, syncphase, OUT.i);
}catch(Exception te){
fail(te.getMessage());
}
OutputFile ws=new OutputFile(1);
ProcessElement m=new mul();
m.setSource(IN_IMAG.i, pe, OUT.i);
m.setSource(IN.i, ConstStream.c(0.9995), OUT.i);
advancerRegistry.registerAdvancer(ws);
advancerRegistry.registerAdvancer(sync);
advancerRegistry.registerAdvancer(syncphase);
ws.setSource(0, m, OUT.i);
advancerRegistry.registerAdvancer(m);
for(double time=0; time<10; time+=1/globalParameters.getSampleRate()){
advancerRegistry.advanceAll();
}
try{
File f=new File("880HzSyncSaw.wav");
BufferedOutputStream fos=new BufferedOutputStream(new FileOutputStream(f), fileBufferSize);
ws.setFormat(FileFormats.FMT_WAVE_S16);
ws.write(fos);
fos.close();
}catch(IOException ex){
fail(ex.getMessage());
}
advancerRegistry.unregisterAdvancer(pe);
advancerRegistry.unregisterAdvancer(ws);
advancerRegistry.unregisterAdvancer(m);
NativeObjects.unregisterNativeObject(pe);
NativeObjects.unregisterNativeObject(ws);
NativeObjects.unregisterNativeObject(m);
pe=new Cosine();
advancerRegistry.registerAdvancer(pe);
ws=new OutputFile(1);
advancerRegistry.registerAdvancer(ws);
m.setSource(IN_IMAG.i, pe, OUT.i);
m.setSource(IN.i, ConstStream.c(0.5), OUT.i);
ws.setSource(0, m, OUT.i);
try{
pe.setSource(FREQUENCY.i, freq, OUT.i);
}catch(Exception te){
fail(te.getMessage());
}
for(double time=0; time<10; time+=1/globalParameters.getSampleRate()){
advancerRegistry.advanceAll();
}
try{
File f=new File("880HzSine.wav");
BufferedOutputStream fos=new BufferedOutputStream(new FileOutputStream(f), fileBufferSize);
ws.setFormat(FileFormats.FMT_WAVE_S16);
ws.write(fos);
fos.close();
}catch(IOException ex){
fail(ex.getMessage());
}
advancerRegistry.unregisterAdvancer(pe);
NativeObjects.unregisterNativeObject(pe);
NativeObjects.unregisterNativeObject(ws);
pe=new Cosine();
ProcessElement pe2=new Cosine();
ProcessElement mix=new Mixer();
advancerRegistry.registerAdvancer(pe2);
advancerRegistry.registerAdvancer(pe);
advancerRegistry.registerAdvancer(mix);
mix.setSource(-1, pe2, StandardParameters.OUT.i);
mix.setSource(-1, new ConstStream(0.5), StandardParameters.OUT.i);
mix.setSource(-2, new ConstStream(0.5), StandardParameters.OUT.i);
ws=new OutputFile(1);
advancerRegistry.registerAdvancer(ws);
try{
pe2.setSource(StandardParameters.FREQUENCY.i, new ConstStream(1), StandardParameters.OUT.i);
pe.setSource(StandardParameters.FREQUENCY.i, freq, StandardParameters.OUT.i);
pe.setSource(StandardParameters.DUTYCYCLE.i, mix, StandardParameters.OUT.i);
m.setSource(StandardParameters.IN_IMAG.i, pe, StandardParameters.OUT.i);
m.setSource(StandardParameters.IN.i, new ConstStream(0.5), StandardParameters.OUT.i);
ws.setSource(0, m, OUT.i);
}catch(Exception te){
fail(te.getMessage());
}
for(double time=0; time<10; time+=1/globalParameters.getSampleRate()){
advancerRegistry.advanceAll();
}
try{
File f=new File("880HzSineMod.wav");
BufferedOutputStream fos=new BufferedOutputStream(new FileOutputStream(f), fileBufferSize);
ws.setFormat(FileFormats.FMT_WAVE_S16);
ws.write(fos);
fos.close();
}catch(IOException ex){
fail(ex.getMessage());
}
advancerRegistry.clear();