element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi-Fest
  • Challenges & Projects
  • Design Challenges
  • Pi-Fest
  • More
  • Cancel
Pi-Fest
Blog e-tabla part #1: Intro and Audio
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Leaderboard
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: arjuna_dev
  • Date Created: 26 Jun 2022 5:43 PM Date Created
  • Views 1210 views
  • Likes 2 likes
  • Comments 0 comments
  • audio
  • pi
  • circuitpython
  • raspberry pi pico
  • micropython
  • pi-fest
  • MakeSomeNoise
Related
Recommended

e-tabla part #1: Intro and Audio

arjuna_dev
arjuna_dev
26 Jun 2022

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:

image

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:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image


And this is that interesting pitch changing sound:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image


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:


You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image


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:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image


Notice I have bigger speakers now! I savaged them from a big broken flat TV monitor Smiling imp



Stay tuned for touch sensitivity integration!

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube