Changeset 1190

Show
Ignore:
Timestamp:
08/04/08 05:23:09 (4 months ago)
Author:
cdavid
Message:

More work on Device class: can now set samplerate/channels.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/audiolab/scikits/audiolab/soundio/_alsa.pyx

    r1189 r1190  
    6464        int snd_pcm_close(snd_pcm_t *) 
    6565 
     66        int snd_pcm_set_params(snd_pcm_t *, snd_pcm_format_t, 
     67                        snd_pcm_access_t, unsigned int, 
     68                        unsigned int, int, unsigned int) 
     69 
    6670        char* snd_strerror(int error) 
    6771 
     
    113117        return cardname 
    114118 
    115 cdef class Device
     119cdef class PCM
    116120        cdef snd_pcm_t* pcmhdl 
    117121        cdef public char* name 
     
    130134                if self.pcmhdl: 
    131135                        snd_pcm_close(self.pcmhdl) 
     136 
     137cdef class Device: 
     138        cdef PCM pcm 
     139        cdef unsigned int samplerate 
     140        cdef unsigned int channels 
     141        def __init__(self, samplerate = 48000, channels = 1, 
     142                     format = SND_PCM_FORMAT_S16, 
     143                     access = SND_PCM_ACCESS_RW_INTERLEAVED): 
     144                self.pcm = PCM() 
     145 
     146                self.samplerate = samplerate 
     147                self.channels = channels 
     148 
     149                st = snd_pcm_set_params(self.pcm.pcmhdl, format, access, channels, 
     150                                        samplerate, 1, 1000000) 
     151                if st < 0: 
     152                        raise AlsaException() 
     153 
     154        def _get_name(self): 
     155                return self.pcm.name 
     156        name = property(_get_name)