示例#1
0
 def _getStream(self, sampleRate, channels, blockSize):
     """Strict check for this format or create new
     """
     label = getStreamLabel(sampleRate, channels, blockSize)
     # try to retrieve existing stream of that name
     if label in self:
         pass
     # on some systems more than one stream isn't supported so check
     elif sys.platform == 'win32' and len(self):
         raise exceptions.SoundFormatError(
             "Tried to create audio stream {} but {} already exists "
             "and {} doesn't support multiple portaudio streams"
                 .format(label, list(self.keys())[0], sys.platform)
         )
     else:
         # create new stream
         self[label] = _SoundStream(sampleRate, channels, blockSize,
                                    device=defaultOutput)
     return label, self[label]
示例#2
0
 def getStream(self, sampleRate, channels, blockSize):
     """Gets a stream of exact match or returns a new one
     (if possible for the current operating system)
     """
     label = getStreamLabel(sampleRate, channels, blockSize)
     # try to retrieve existing stream of that name
     if label in self.keys():
         pass
     # on some systems more than one stream isn't supported so check
     elif sys.platform == 'win32' and len(self):
         raise exceptions.SoundFormatError(
             "Tried to create audio stream {} but {} already exists "
             "and {} doesn't support multiple portaudio streams".format(
                 label,
                 self.keys()[0], sys.platform))
     else:
         # create new stream
         self[label] = _SoundStream(sampleRate, channels, blockSize)
     return label, self[label]