Tabla
The tabla is an Indian percussion instrument. It is one of the main instruments in classical Indian music. It is composed of two drums, one made out of wood and the other has a metallic body:
It is in nature a bit bulky and difficult to travel with.
The idea of the e-tabla project is is to create an electronic version of the instrument that is portable and easy to travel with while still enabling the player to recreate the wide variety of sounds available in the original instrument.
The thinner drum can produce 7 distinct sounds. The more round one can produce 3 distinct sounds or 4 actually if you count that one of them can be made to change pitch while it is being played. This is how the tabla sounds:
And this is that interesting pitch changing sound:
One of the interesting challenges of the project will be to be able to detect which sound is the user trying to play. Including that funky sounding slide troke!
Pi Pico and Audio
The project will try to leverage the 2MB flash memory from the pico to store audio files. My first attempt was using only PWM and mp3 files. I added a cheap amplifier module. The results were a bit noisy and also not loud enough:
I moved on to using a MAX98357A (I2S DAC + Amp) breakout board. I used Adafruit's audiomp3 library. Result where not good. It seems somehow the limiting factor when using this library becomes the RAM. So even though I could store 2MB of audio files, the library ran into problems when the SRAM limit of 264KB was exceeded. This was my last messy code while trying to debug that:
import audiomp3
mp3stream1 = audiomp3.MP3Decoder(open("tabla_samples/01.mp3", "rb"))
mp3stream2 = audiomp3.MP3Decoder(open("tabla_samples/07.mp3", "rb"))
mp3stream3 = audiomp3.MP3Decoder(open("tabla_samples/04.mp3", "rb"))
import board
import audiobusio
import gc
from time import sleep
audio = audiobusio.I2SOut(board.GP0, board.GP1, board.GP2)
tablaSounds = [
"tabla_samples/01.mp3",
"tabla_samples/07.mp3",
"tabla_samples/04.mp3",
"tabla_samples/03.mp3",
"tabla_samples/08.mp3",
"tabla_samples/05.mp3",
"tabla_samples/02.mp3",
"tabla_samples/06.mp3",
]
print(gc.mem_free())
audio.play(mp3stream1)
while audio.playing:
pass
audio.play(mp3stream2)
while audio.playing:
pass
audio.play(mp3stream3)
while audio.playing:
pass
mp3stream1 = audiomp3.MP3Decoder(open(tablaSounds[3], "rb"))
mp3stream2 = audiomp3.MP3Decoder(open(tablaSounds[4], "rb"))
mp3stream3 = audiomp3.MP3Decoder(open(tablaSounds[5], "rb"))
audio.play(mp3stream1)
while audio.playing:
pass
audio.play(mp3stream2)
while audio.playing:
pass
audio.play(mp3stream3)
while audio.playing:
pass
mp3stream1 = audiomp3.MP3Decoder(open(tablaSounds[6], "rb"))
mp3stream2 = audiomp3.MP3Decoder(open(tablaSounds[7], "rb"))
audio.play(mp3stream1)
while audio.playing:
pass
audio.play(mp3stream2)
while audio.playing:
pass
print(gc.mem_free())
I finally moved on to playing .wav files and had good results. I followed this Adafruit tutorial, remembering that "CircuitPython supports mono or stereo, at 22 KHz sample rate (or less) and 16-bit WAV format." (you ca use Audacity to export audio files with those requirements).
Here is the code:
import audiocore
import board
import audiobusio
audio = audiobusio.I2SOut(board.GP0, board.GP1, board.GP2)
right_drum_strokes = ["Na", "Ta", "Tin", "Te", "Ti", "Tun", "TheRe"]
left_drum_strokes = ["Ghe", "Ga", "Ke"]
all_drum_strokes = right_drum_strokes + left_drum_strokes
waveObjects = []
for i in range(0, len(all_drum_strokes)):
waveObjects.append(audiocore.WaveFile(open("tabla_samples/" + all_drum_strokes[i] + ".wav", "rb")))
while True:
for i in range(0, len(all_drum_strokes)):
audio.play(waveObjects[i])
while audio.playing:
pass
And here is how it sounds:
Notice I have bigger speakers now! I savaged them from a big broken flat TV monitor
Stay tuned for touch sensitivity integration!