def writeToSerial(self, data): if serialDebug: ansi.stdout( "{style.bold.fg.black}Arduino <- RPi :{style.none} {data!r}", data=data ) self.serial.write(data)
def readFromSerial(self): data = self.serial.readline() if serialDebug: ansi.stdout( "{style.bold.fg.black} Arduino -> RPi:{style.none} {data!r}", data=data ) return data
def displayFileStarted(sampleGen): print() ansi.stdout( "Playing audio file: {style.fg.blue}{file.currentFilename}{style.none}\n" "{style.bold.fg.black}channels:{style.none} {file.channels}" " {style.bold.fg.black}sample rate:{style.none} {file.samplerate} Hz" " {style.bold.fg.black}duration:{style.none} {file.duration} s", file=sampleGen )
def getData(self): ansi.stdout( "{cursor.col.0}{clear.line.all}Current time:" " {style.bold}{file.elapsedTime: >7.2f}{style.none} / {file.duration: <7.2f}", file=self.sampleGen, suppressNewline=True ) # fill the chunk with audio data from the stream source return self.sampleGen.nextChunk()
def queueNextSound(self, event=None): chunk = sampleGen.nextChunk() chunk.play() ansi.stdout( "{cursor.col.0}{clear.line.all}Current time:" " {style.bold}{file.elapsedTime: >7.2f}{style.none} / {file.duration: <7.2f}", file=sampleGen, suppressNewline=True )
def queueNextSound(self, event=None): if self.debug: ansi.stdout( "{cursor.col.0}{clear.line.all}Current time:" " {style.bold}{file.elapsedTime: >7.2f}{style.none} / {file.duration: <7.2f}", file=self.sampleGen, suppressNewline=True ) chunk = self.sampleGen.nextChunk() if self.pcm: self.pcm.write(chunk)
def _onSongChanged(self, tags, songInfo): print() ansi.stdout( "Analyzing audio file: {style.fg.blue}{file.currentFilename}{style.none}\n" "{style.bold.fg.black}channels:{style.none} {file.channels}" " {style.bold.fg.black}sample rate:{style.none} {file.samplerate} Hz" " {style.bold.fg.black}duration:{style.none} {file.duration} s", file=self.sampleGen ) try: self.messageQueue.put_nowait(('songChange', self.sampleGen.currentFilename, songInfo)) except QueueFull: ansi.error("Message queue to light process full! Continuing...") self.csv.writerow([ '{} Hz'.format(f) for f in self.analyzer.fftFrequencies(self.sampleGen.samplerate) ])