Hi there
I decided I want to give a small contribution to this awesome project which I just love:
I want to add sampling capacity to Samplerbox
It's pretty straightforward basically it has a button to GPIO (could be momentary but I prefer a switch toggle) which records a wav file as long as the button is held
now what I would like is to add this feature:
after I press enable the record switch button recording starts only when I press a MIDI Key (i.e. Midi note 36) and save the file in the current preset (overwriting if necessary) with the name of the MIDI note I pressed (i.e. 36.wav) and records for as long as the key is pressed.
Then I can press another key (i.e. Midi note 37) and it records another audio file and save it in the same folder with the name of the relative note (i.e. 37.wav)
Then the user can switch back the record switch toggle to playback mode (Record OFF) and he can play the sounds he already recorded..
Also it would need to record in the current preset folder (which I am not sure how ro redirect)
very simple and elegant solution
This is the bit of code I am adding so far but his only enable the recording of the file
Anyone can help with this adding the necessary code or suggesting what I can add?
Thank you guys <3
Code=====================
import RPi.GPIO as gpio
from recorder import Recorder
gpio.setmode(gpio.BCM)
class ButtonRecorder(object):
def __init__(self, filename):
self.filename = filename
gpio.setup(23, gpio.IN, pull_up_down=gpio.PUD_UP)
self.rec = Recorder(channels=2)
def start(self):
gpio.add_event_detect(23, gpio.FALLING, callback=self.falling, bouncetime=10)
def rising(self, channel):
gpio.remove_event_detect(23)
print 'Button up'
gpio.add_event_detect(23, gpio.FALLING, callback=self.falling, bouncetime=10)
self.recfile.stop_recording()
self.recfile.close()
def falling(self, channel):
gpio.remove_event_detect(23)
print 'Button down'
gpio.add_event_detect(23, gpio.RISING, callback=self.rising, bouncetime=10)
self.recfile = self.rec.open(self.filename, 'wb')
self.recfile.start_recording()
rec = ButtonRecorder('36.wav')
rec.start()
try:
raw_input()
except KeyboardInterrupt:
pass
gpio.cleanup()
=================================================