[SOLVED] Making the Buzzer Deck play sounds from a Python script

Post here to get support
Post Reply
wingjet
Beginner
Posts: 2
Joined: Sun Nov 12, 2017 10:23 pm

[SOLVED] Making the Buzzer Deck play sounds from a Python script

Post by wingjet »

Hello, I installed the buzzer expansion deck to my crazyflie and have seen it play different sounds through the client. Is it possible to call these sounds from a python script? Is it also possible to create new sequences of sounds from python or do you need to go through the firmware to do that?
Last edited by wingjet on Thu Nov 30, 2017 12:48 am, edited 1 time in total.
marcus
Bitcraze
Posts: 659
Joined: Mon Jan 28, 2013 7:02 pm
Location: Sweden
Contact:

Re: Making the Buzzer Deck play sounds from a Python script

Post by marcus »

Hi,

It's possible to set tones or melodies from the Python API using parameters, but this will not work well for playing longer sequences because the timing will probably be off. If you want a new melody the best is to modify the firmware.

The sound_cf2.c contains everything you need. Just clone the Crazyflie firmware, edit this file, rebuild, flash and you will be able to set your new melody using parameters in the Python API. If you don't have a build environment locally you can download the Bitcraze VM.

Have a look at this example to see how to build your melody. Then add it to this structure. Now you can set your new melody by setting the parameter sound.effect to the index in the array.

If you just want to play specific tunes from the Python API you can set the parameter sound.effect to 12 and then setting the parameters sound.freq and sound.ratio to the desired values.
Post Reply