AlexT posted May 8 '17, 21:33:
Does anyone know how to display the name of the playing .wav-file on a 16x2-Display?
I implemented the code for using an 16x2 via i2C-Backpack David Hilowitz and everything works fine. It maybe sounds weird in the first place but I use this as backing track player and the filename is the trackname...
How can I call the filename of the playing .wav file in the samplerbox.py and display it with lcd_string() in the second line? It should only be displayed when the track is playing. Maybe display with note_on and clear with note_off.
thank you in advance
AlexM posted May 11 '17, 02:26:
You could add a
filename property to the Sound object which is populated during loading (
LoadSamples()). When a new sample is triggered by
self.filename to the display.
AlexM posted May 11 '17, 04:24:
Got ahead of myself there - the Sound object already has the filename/filepath! >> https://github.com/josephernest/SamplerBox/blob/master/samplerbox.py#L129
We can add something to the
play method like this:
def play(self, note):
snd = PlayingSound(self, note)
fname_to_lcd = self.fname.rsplit('/', 1)[-1] # get the filename after last slash
AlexT posted May 11 '17, 16:53:
Thank you for your quick response, this looks promising. I will test it as soon as possible!
AlexT posted May 17 '17, 22:34:
It works perfectly, just added the ', 2' in the lcd string for line 2. I also changed polyphony to 1, so there is no conflict if accidentally a second "note" is hit. (Don't know if this is even a problem...)