hallo,
in the code below, if i omit to close the buffer, successive diskin
creation fails to play the sound file from the very beginning (only
the first buffer is played correctly, then the synth skips to where
it has been before), although the buffer and the synth are both
destroyed, when i press the stop button. ?? so it seems, scsynth
doesn't "forget" the buffer, even after a /b_free ... ?
ciao, -sciss-
s = Server.local;
s.boot;
(
var kCALL_CLOSE = true; // if false, diskin playhead
position reset fails
var hView, vView;
var ggSource;
var synthSrc, bufSrc;
var numChannels = 2;
// your audio folder and file here
var folder = "/Volumes/ProtoolsSound2/Users/rutz/Trailer/
audio_material/opt/";
var sfPath = folder ++ "tapeOpt.aif";
var monitor;
w = SCWindow( "Trailer Layer Test", Rect( 40, 400,
400, 400 ));
vView = SCVLayoutView( w, Rect( 0, 0, 400, 400 ));
hView = SCHLayoutView( vView, Rect( 0, 0, 400, 24 ));
ggSource = SCButton( hView, Rect( 0, 0, 96, 32 ));
ggSource.states = [["Play", Color.black, Color.white],
["Stop", Color.white, Color.blue]];
ggSource.action = { arg gg;
if( synthSrc.isNil.not, {
synthSrc.free;
synthSrc = nil;
// if the following line is not executed,
// repeated re-creation of the synth will
// not reset the diskin playhead position:
//
if( kCALL_CLOSE, { bufSrc.close });
bufSrc.free;
bufSrc = nil;
});
if( gg.value == 1, {
synthSrc = Synth.basicNew( \sfPlay2, s );
bufSrc = Buffer.cueSoundFile( server: s, path: sfPath,
numChannels: numChannels,
completionMessage: { arg buf;
synthSrc.newMsg( s.asTarget, [ \i_buf, buf.bufnum,
\i_aOutBus, 0 ]);
});
});
};
SynthDef( \sfPlay2, { arg i_buf, i_aOutBus;
Out.ar( i_aOutBus, DiskIn.ar( numChannels, i_buf ));
}).send( s );
w.onClose = {
if( bufSrc.isNil.not, { bufSrc.free; });
};
w.front;
)
_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users