How to use the pyo.TableRead function in pyo

To help you get started, we’ve selected a few pyo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wehr-lab / autopilot / sound / sounds.py View on Github external
def init_sound(self):
        fs, audio = wavfile.read(self.path)
        if audio.dtype in ['int16', 'int32']:
            audio = int_to_float(audio)

        # load file to sound table
        if self.server_type == 'pyo':
            self.dtable = pyo.DataTable(size=audio.shape[0], chnls=prefs.NCHANNELS, init=audio.tolist())

            # get server to determine sampling rate modification and duration
            server_fs = self.dtable.getServer().getSamplingRate()
            self.duration = float(self.dtable.getSize()) / float(fs)
            self.table = pyo.TableRead(table=self.dtable, freq=float(fs) / server_fs,
                                       loop=False, mul=self.amplitude)

        elif self.server_type == 'jack':
            self.duration = float(audio.shape[0]) / fs
            # resample to match our audio server's sampling rate
            if fs != self.fs:
                new_samples = self.duration*self.fs
                audio = resample(audio, new_samples)

            self.table = audio
github wehr-lab / autopilot / core / sounds.py View on Github external
def load_file(self):
        # load file to sound table
        print(self.path)
        sys.stdout.flush()
        self.snd_table = pyo.SndTable(self.path, chnl=2)
        self.table = pyo.TableRead(self.snd_table, freq=self.snd_table.getRate(),
                                   loop=False, mul=self.amplitude)
github psychopy / psychopy / psychopy / sound.py View on Github external
def _updateSnd(self):
        self.needsUpdate = False
        doLoop = bool(self.loops != 0)  # if True, end it via threading.Timer
        self._snd = pyo.TableRead(self._sndTable,
                                  freq=self._sndTable.getRate(),
                                  loop=doLoop, mul=self.volume)
github wehr-lab / autopilot / core / sounds.py View on Github external
def TableWrap(audio,duration):
    '''
    Records a PyoAudio generator into a sound table, returns a tableread object which can play the audio with .out()
    '''
    # Duration is in ms, so divide by 1000
    # See https://groups.google.com/forum/#!topic/pyo-discuss/N-pan7wPF-o
    #TODO: Get chnls to be responsive to NCHANNELS in prefs. hardcoded for now
    #audio.play()
    tab = pyo.NewTable(length=(float(duration)/1000),chnls=2) # Prefs should always be declared in the global namespace
    tabrec = pyo.TableRec(audio,table=tab,fadetime=0.01).play()
    sleep((float(duration)/1000))
    tabread = pyo.TableRead(tab,freq=tab.getRate(), loop=0)
    #audio.stop()
    #tabrec.stop()
    return tabread
github wehr-lab / autopilot / core / sounds.py View on Github external
def load_file(self):
        # load file to sound table
        #
        fs, audio = wavfile.read(self.path)
        if audio.dtype in ['int16', 'int32']:
            audio = int_to_float(audio)

        self.dtable = pyo.DataTable(size=audio.shape[0], chnls=2, init=audio.tolist())

        # get server to determine sampling rate modification and duration
        server_fs = self.dtable.getServer().getSamplingRate()
        self.duration = float(self.dtable.getSize())/float(fs)

        self.table = pyo.TableRead(table=self.dtable, freq=float(fs)/server_fs,
                                   loop=False, mul=self.amplitude)
github wehr-lab / autopilot / autopilot / stim / sound / sounds.py View on Github external
Args:
                audio:
                duration:
            """

            if not duration:
                duration = self.duration

            # Duration is in ms, so divide by 1000
            # See https://groups.google.com/forum/#!topic/pyo-discuss/N-pan7wPF-o
            # TODO: Get chnls to be responsive to NCHANNELS in prefs. hardcoded for now
            tab = pyo.NewTable(length=(float(duration) / 1000),
                               chnls=prefs.NCHANNELS)  # Prefs should always be declared in the global namespace
            tabrec = pyo.TableRec(audio, table=tab, fadetime=0.005).play()
            sleep((float(duration) / 1000))
            self.table = pyo.TableRead(tab, freq=tab.getRate(), loop=0)
github wehr-lab / autopilot / stim / sound / sounds.py View on Github external
def table_wrap(self, audio, duration=None):
            '''
            Records a PyoAudio generator into a sound table, returns a tableread object which can play the audio with .out()
            '''

            if not duration:
                duration = self.duration

            # Duration is in ms, so divide by 1000
            # See https://groups.google.com/forum/#!topic/pyo-discuss/N-pan7wPF-o
            # TODO: Get chnls to be responsive to NCHANNELS in prefs. hardcoded for now
            tab = pyo.NewTable(length=(float(duration) / 1000),
                               chnls=prefs.NCHANNELS)  # Prefs should always be declared in the global namespace
            tabrec = pyo.TableRec(audio, table=tab, fadetime=0.005).play()
            sleep((float(duration) / 1000))
            self.table = pyo.TableRead(tab, freq=tab.getRate(), loop=0)
github wehr-lab / autopilot / core / sounds.py View on Github external
def table_wrap(self, audio, duration):
        '''
        Records a PyoAudio generator into a sound table, returns a tableread object which can play the audio with .out()
        '''
        # Duration is in ms, so divide by 1000
        # See https://groups.google.com/forum/#!topic/pyo-discuss/N-pan7wPF-o
        # TODO: Get chnls to be responsive to NCHANNELS in prefs. hardcoded for now
        tab = pyo.NewTable(length=(float(duration) / 1000),
                           chnls=1)  # Prefs should always be declared in the global namespace
        tabrec = pyo.TableRec(audio, table=tab, fadetime=0.01).play()
        sleep((float(duration) / 1000))
        tabread = pyo.TableRead(tab, freq=tab.getRate(), loop=0)
        return tabread