def start_sc(self): try: sc.start(verbose=1, spew=1, startscsynth=1) except OSError: # in case we've already started the synth print 'QUIT!' sc.quit() print 'sfpath: ', self.sfpath self.bnum = sc.loadSnd(self.sfpath, wait=False) print 'bnum: ', self.bnum return 1
def start_sc(self): try: sc.start(verbose=1, spew=1, startscsynth=1) except OSError: # in case we've already started the synth print "QUIT!" sc.quit() print "sfpaths: ", self.sfpaths for i, sfpath in enumerate(self.sfpaths): bnum = sc.loadSnd(os.path.basename(sfpath), wait=False) print "bnum: ", bnum self.sfinfos[i]["bnum"] = bnum return 1
def start_sc(self): try: sc.start(verbose=1, spew=1, startscsynth=1) except OSError: # in case we've already started the synth print 'QUIT!' sc.quit() print 'sfpath: ', self.sfpath for i, sfpath in enumerate(self.sfpaths): bnum = sc.loadSnd(sfpath, wait=False) print 'bnum: ', bnum self.infos[i]['bnum'] = bnum return 1
NOTE that stereo synthdefs take TWO chanels, so if you set out to 2. it will take 2 and 3 to play the stereo. Be careful not to use chanels that are already taken by some other synthdef 0 and 1 are the default sound out chanels, setting a synthdef out to 0 means directing its sound output to the sound card . Sound in from sounds card should be 5 and 6 """ # we need to tell python where the scserver application lives, this # changes between platforms and systems. You might need to edit it. # exedir = '/usr/bin' # where does scsynth live? # sc.start( exedir, verbose=1, spew=0 ) sc.start() # sampler player player = sc.Synth( "StereoPlayer" ) player.bufnum = sc.loadSnd( "numeros.wav", wait=True ) player.rate = 0 # stopped now print "loading bufnum with ID", player.bufnum # delay delay = sc.Synth( "xiiDelay2x2" ) delay.feedback = 0 # init paramenters that we will manipulate in this script delay.fxlevel = 0 # octave octave = sc.Synth( "xiiOctave2x2" ) octave.pitch1 = 0.1 octave.pitch2 = 1 octave.fxlevel = 1 # processed sound octave.level = 0 # clean sound
import sc import time, os # we need to tell python where the scserver application lives, this # changes between platforms and systems. You might need to edit it. # exedir = 'usr/local' # where does scsynth live? # sc.start(exedir, verbose=1, spew=1 ) sc.start(spew=1, verbose=1, startscsynth=0) player2 = sc.Synth("StereoPlayer") player2.bufnum = sc.loadSnd("aaa.wav", wait=True) print "loading bufnum with ID", player2.bufnum time.sleep(8) player = sc.Synth("StereoPlayer") player.bufnum = sc.loadSnd("numeros.wav", wait=True) print "loading bufnum with ID", player.bufnum time.sleep(8) # wait while both sounds play sc.unloadSnd(player.bufnum) sc.unloadSnd(player2.bufnum) player.free() player2.free() sc.quit() print 'quiting'
import sc import time, random seed = random.Random() # we need to tell python where the scserver application lives, this # changes between platforms and systems. You might need to edit it. # exedir = 'usr/local' # where does scsynth live? # sc.start(exedir, verbose=1, spew=1 ) sc.start() player = sc.Synth( "StereoPlayer" ) ## outbus=0, bufnum=0, amp=1, pan=0, mute=1, start=0, end=1, rate=1, fps=12, index=0; player.bufnum = sc.loadSnd( "numeros.wav" ) print "loading bufnum with ID", player.bufnum timeout = time.time() + 10 # secs while time.time() < timeout : player.pan = seed.random() player.amp = seed.random() player.rate = (seed.random() - 0.5) * 6 # range float -3 to 3 time.sleep(2) # every two secs print "timeout in %f secs" % (timeout - time.time()) sc.unloadSnd( player.bufnum ) player.free()
mygroup = sc.Group( ) print 'created new group with ID ', mygroup.groupID playerlist = [] for s in xrange(3) : player = sc.Synth( "StereoPlayer", addTargetID=mygroup.groupID ) ## outbus=0, bufnum=0, amp=1, pan=0, mute=1, start=0, end=1, rate=1, fps=12, index=0; player.bufnum = 0 # need to declare here the vars we will be manipulating later player.amp = 1 player.pan = 0 player.rate = 1 playerlist.append(player) ## mygroup.bufnum = sc.loadSnd( "numeros.wav" ) ## all share same sound bufnum mygroup.outbus = 0 # all use same bus print "loading bufnum with ID", player.bufnum timeout = time.time() + 10 # secs while time.time() < timeout : ## all share same pan and amp mygroup.pan = (seed.random()*2)-1 # -1 to 1 mygroup.amp = seed.random() print 'pan', mygroup.pan, 'amp', mygroup.amp # but each has a different rate for player in playerlist : player.rate = (seed.random() - 0.5) * 6 # range float -3 to 3
mygroup = sc.Group() print 'created new group with ID ', mygroup.groupID playerlist = [] for s in xrange(3): player = sc.Synth("StereoPlayer", addTargetID=mygroup.groupID) ## outbus=0, bufnum=0, amp=1, pan=0, mute=1, start=0, end=1, rate=1, fps=12, index=0; player.bufnum = 0 # need to declare here the vars we will be manipulating later player.amp = 1 player.pan = 0 player.rate = 1 playerlist.append(player) ## mygroup.bufnum = sc.loadSnd("numeros.wav") ## all share same sound bufnum mygroup.outbus = 0 # all use same bus print "loading bufnum with ID", player.bufnum timeout = time.time() + 10 # secs while time.time() < timeout: ## all share same pan and amp mygroup.pan = (seed.random() * 2) - 1 # -1 to 1 mygroup.amp = seed.random() print 'pan', mygroup.pan, 'amp', mygroup.amp # but each has a different rate for player in playerlist: player.rate = (seed.random() - 0.5) * 6 # range float -3 to 3