[Microbit-Python] Musical silliness...

Nicholas H.Tollervey ntoll at ntoll.org
Thu Oct 15 15:34:34 CEST 2015


:-)

On 15/10/15 13:20, Damien George wrote:
> I agree to renaming "tune" to "play" and having the pin parameter
> named "pin" and second position and optional (with default pin0).
> 
> But, at the risk of openning a can of worms:
> 
> 1. Why not play_note, play_pitch, play_tune?  The original reason for
> calling tune tune is that "play" was implicit, like it is implicit in
> note and pitch.
> 
> 2. Why not merge note and tune and let "play" take either a string (an
> individual note) or a list of strings (a tune)?
> 

I like this idea because it solves 1 and feels natural. on any
instrument you can play just a single note or a melody - the same verb
is used. If we can override the function then it'd further simplify things.

> 3. If we are giving up polyphony (which is fine) why not have a method
> set_pin which sets the output pin to use for all operations (including
> stop)?
> 

I guess because there is a chance someone *could* still do polyphony if
they were more of a maker/hacker type rather than a kid and it'd be
cool. We'd be closing down that option if we didn't allow people to
specify the pin.

I'll have a go at updating the API specification on the wiki this
evening and ping people when it's good for feedback.

I'd like to add that such conversations are one of the reasons I love
software development. It feels good to think about and implement things
like this.

Best wishes,

N.

> 
> On Thu, Oct 15, 2015 at 12:39 PM, Nicholas H.Tollervey <ntoll at ntoll.org> wrote:
>> On 15/10/15 12:22, Larry Hastings wrote:
>>>
>>>
>>> On 10/15/2015 12:54 AM, Nicholas H.Tollervey wrote:
>>>> * Specification of the pin is done via a named parameter called "pin"
>>>> that has the default value of microbit.pin0.
>>>> * music.tune should be renamed to music.play
>>>>
>>>> So we get code like this:
>>>>
>>>>>>> from microbit import music
>>>>>>> music.play(music.NYAN)
>>>>>>> import microbit
>>>>>>> music.note('c4:4', pin=microbit.pin1)
>>>>
>>>
>>> LGTM.  I appreciate your open-mindedness!  I was worried I was
>>> resurrecting an old talked-to-death topic that only you still had the
>>> stamina to argue about.  ;-)
>>>
>>
>> My default setting is, "I'm probably wrong" and I *enjoy* constructive
>> critique. I'm not precious about my opinions and would rather people
>> knock holes in them.
>>
>> My feeling is that an API needs to earn its design through some sort of
>> Socratic / devil's advocate like process of poking holes in it. Anything
>> that makes an API simpler, easier and clearer is a good thing - even if
>> it takes longer or requires people to change position.
>>
>>> One tiny bit of bikeshedding.  "output=" instead of "pin=" for the named
>>> parameter?  Yes?  No?  Just a thought, I'm not wedded to it.
>>>
>>
>> I agree with Michael and Matthew. It's unambiguous and kid friendly.
>>
>> N.
>>
>>> Cheers,
>>>
>>>
>>> //arry/
>>>
>>>
>>> _______________________________________________
>>> Microbit mailing list
>>> Microbit at python.org
>>> https://mail.python.org/mailman/listinfo/microbit
>>>
>>
>>
>>
>> _______________________________________________
>> Microbit mailing list
>> Microbit at python.org
>> https://mail.python.org/mailman/listinfo/microbit
>>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://mail.python.org/mailman/private/microbit/attachments/20151015/f523a1d9/attachment.sig>


More information about the Microbit mailing list