Пример #1
0
    def __init__(self, metro, orcObj, *cs):
        "SchedObj is a Csound timer instance, orcObJ is a CsOrcConstructor Object"
        #self.Timer = csnd.CsoundTimer()
        self.metro = metro
        #self.schedObj = schedObj
        self.orcObj = orcObj
        if len(cs) == 0:
            cs = Csound()
            self.csound = Csound.csound
        else:
            self.csound = cs[0]
        self.csound.setOrchestra(orcObj.exportOrc())
        self.csound.setScore(orcObj.sco)

        if platform == "Sugar":
            self.csound.setCommand(
                "csound -b256 -B2048 -+rtaudio=alsa -odac --expression-opt --sched=1 -d -m0 /tmp/tmp.orc /tmp/tmp.sco"
            )
        else:
            self.csound.setCommand(
                "csound -b256 -B2048 -odac --expression-opt -d -m0 /tmp/tmp.orc /tmp/tmp.sco"
            )
        self.csound.exportForPerformance()
        self.csound.compile()
        self.Channels = channels(self.csound)
        self.perf = csnd.CsoundPerformanceThread(self.csound)
        self.perf.Play()
        self.perf.SetProcessCallback(self.metro.poll, 0)
Пример #2
0
def csoundThreadRoutine(s):
    
    '''
    
    some stuff i copied & hacked from both
    victors cb.py example
    & the wxController.py example
    
    as ultimately there will be wx components
    introduced, i wanted to make sure
    some token representation
    of any necessary threading capability 
    was in place
    
    '''
    
    cs = csnd.CppSound()
    
    # this to me seems the neatest way to wrap csound code
    cs.Compile("gns003.csd")
    
    # Perform in blocks of ksmps
    performanceThread = csnd.CsoundPerformanceThread(cs)
    
    if s != "":
        
        print s
        performanceThread.InputMessage(s)

    s = ""
Пример #3
0
 def reset(self):
     """Resets Csound, ready for a new CSD"""
     if not self.ready:
         self.perf.Stop()
         self.perf.Join()
         self.on = False
         self.paused = False
         self.perf = csnd.CsoundPerformanceThread(self.csound)
         self.ready = True
Пример #4
0
 def recompile(self):
     """Recompiles the set CSD.
        returns zero if successful"""
     if not self.ready and self.name !=  "0":
        self.perf.Stop()
        self.perf.Join()
        self.on = False
        self.paused = False
        self.perf = csnd.CsoundPerformanceThread(self.csound)
        if self.arglist != None:
         res = self.csound.Compile(self.arglist.argc(),self.arglist.argv())
        else:
         res = self.csound.Compile("%s/%s" % (self.path,self.name))
        if(res): self.ready = True
        return res
Пример #5
0
 def __init__(self, act, colour=(-1, -1, -1), vert=True):
     """constructor
         act:  activity object
         colour: bg colour RGB tuple (R,G, B)
         vert: True for vertical topmost arrangement, horiz. otherwise."""
     locale.setlocale(locale.LC_NUMERIC, 'C')
     self.csound = csnd.Csound()
     self.perf = csnd.CsoundPerformanceThread(self.csound)
     BasicGUI.__init__(self, act, colour, vert)
     self.ready = True
     self.on = False
     self.paused = False
     self.name = "0"
     self.arglist = None
     self.replay = False
     self.stopcb = True
Пример #6
0
outs  a2,a2

endin
 ''')

csound.setScore('''
            f1 0 8192 10 1
            i1 0 16
            e
            ''')

csound.setCommand(
    'csound -h -d -r 44100 -k 441 -m128 -b4096 -B100 -odac8 test.orc test.sco')
csound.exportForPerformance()
csound.compile()
performanceThread = csnd.CsoundPerformanceThread(csound)
performanceThread.Play()

ESCAPE = '\033'

# Number of the glut window.
window = 0


# A general OpenGL initialization function.  Sets all of the initial parameters.
def InitGL(Width,
           Height):  # We call this right after our OpenGL window is created.
    glClearColor(0.0, 0.0, 0.0,
                 0.0)  # This Will Clear The Background Color To Black
    glClearDepth(1.0)  # Enables Clearing Of The Depth Buffer
    glDepthFunc(GL_LESS)  # The Type Of Depth Test To Do
Пример #7
0
 def startThread(self):
     if self.Compile(self.csd) == 0:
         self.pt = csnd.CsoundPerformanceThread(self)
         self.pt.Play()