[Microbit-Python] My visit to the BBC today

Damien George damien.p.george at gmail.com
Sun Sep 27 12:52:46 CEST 2015


Hi David,

Regarding your thoughts on extended music support.  I tried playing an
audio sample on the microbit (4k/s, mono) but it's very difficult to
get working.  Because there is no proper DAC you need to use the PWM
output at a very high frequency (highest seems to be 30kHz) then
change the duty ratio at 4kHz to output the audio data.  You then need
an external low-pass filter (cap+resistor) to make it a proper analog
signal for the speaker.  But the microbit doesn't have enough power on
its pin to drive the (passive) filter and the speaker.  It might work
with very high impedance headphones, or with an active filter
(basically an external amplifier), but I didn't try these options
because they are getting out of the scope of what kids can wire up.

Of course, we could do anything if we could make hardware add-on
modules (eg a DAC over SPI) but that's not really feasible at this
point :)

Note being able to do proper analog signals means that audio synth is
also off the table for the time being (I don't think you can do
attack-sustain-decay-release with a purely digital signal...?).

So at the moment we just have "music", which is playing a simple
square-wave "note" using PWM.  That is capable of driving an external
speaker (or headphones).

Multiple channel music is possible because there are 3 timers in the
MCU, and each one would be needed to provide a different frequency for
the note.  At the moment only timer2 is supported by mbed and the DAL
so we'd need to do some low-level hacking to get 3 independent music
channels.

Regarding MIDI: given the above constraints (ie no proper analog
output) how would you imagine MIDI working?

Cheers,
Damien.



On Fri, Sep 25, 2015 at 9:19 AM, Nicholas H.Tollervey <ntoll at ntoll.org> wrote:
> Hi,
>
> Comments in-line...
>
> On 24/09/15 23:33, David Whale wrote:
>> Just some random thoughts....
>>
>> Background music would be awesome (in the same way that Damien has
>> surfaced background animations).
>>
>
> +1
>
>> I reckon if you could find a way to use the internal fibre scheduling
>> safely, you could have 3 channels running, one on each pin, and
>> "externally mix them" with resistors or capacitors into a single
>> speaker. This would give you 3 channel sound just like the original
>> AY-3-8910 chip on the BBC Micro!!! My ultimate test here would be to
>> play "Eurythmics: Sweet dreams are made of this" and "Stranglers:Golden
>> Brown" in the same arrangements as the original ones done on the BBC
>> micro!!!
>>
>
> Hahahaha... you had those programs too..? Did you also have the Bach
> Toccata and Fugue (another piece of musical programming amazement)..?
>
>> The other thing that would be cool is an external tool that converts a
>> MIDI file into the python data structures that plays that same music.
>> That would then be a really easy way to bring in other pieces, as there
>> are plenty of MIDI editors and sources of MIDI on the internet.
>>
>
> MIDI is a very simple standard. IIRC it's just channels (giving you
> instruments) along with numbers representing pitches and an offset so
> stuff gets played at the correct time.
>
>> Envelopes - the AY-3-8910 on the beeb had ADSR envelopes. You loaded 4
>> numbers into registers and it did the attack, delay, sustain and release
>> for you automatically, and this made it possible to do really nice
>> phrasing and expression.
>>
>
> I remember those. Combined with the "noise" channel (0) you could get
> some interesting effects.
>
>> The touch sensing works great now - how about something akin to the new
>> PiPiano that Pimoroni made for the Pi based on Zachs original Pi Piano???
>>
>> All of these are a *bit* 1980's demo (Nicholas will understand that quote!)
>>
>
> Nothing wrong with the 1980s (well, the good bits of the 1980s)... ;-)
>
>> There is a really awesome opportunity to implement MIDI or OSC support
>> for linking to external devices and using the MicroBit as the
>> programmable sequencer or controller for them. Python support for either
>> in some way would be a "game changer" (not my words, someone else's
>> words!) - think micro:bit gestures controlling an external soft MIDI
>> synth on a bigger computer. Think linking that to DMX lighting and
>> controlling the school stage lights with it too in sync with the music -
>> the micro:bit as a performance device!
>>
>
> EXACTLY! That's where I'm going with this...
>
>> Just random ideas. Shoot them down.
>>
>> D
>>
>
> Far better to make them fly! ;-)
>
> N.
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>


More information about the Microbit mailing list