Example #1
0
 def writeToSerial(self, data):
     if serialDebug:
         ansi.stdout(
                 "{style.bold.fg.black}Arduino <- RPi :{style.none} {data!r}",
                 data=data
                 )
     self.serial.write(data)
Example #2
0
 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
Example #3
0
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
            )
Example #4
0
    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()
Example #5
0
    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
                )
Example #6
0
    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)
Example #7
0
    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)
            ])