Page 1 of 1
[SOLVED] Making the Buzzer Deck play sounds from a Python script
Posted: Mon Nov 27, 2017 8:16 pm
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?
Re: Making the Buzzer Deck play sounds from a Python script
Posted: Tue Nov 28, 2017 10:01 am
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.