I find the names play_pattern and play_pattern_timed confusing. When I first tried Sonic Pi, I wrote my own melody function because I didn't realise something already existed.
I suggest that they both be obsoleted by play_melody, which can use an optional argument in the case that we want to default it to one beat per note.
I'm happy to submit a pull request if this is a welcome change. If so, should the old functions be preserved for backwards compatibility?
You can always write your own for use in SP eg
define :melody do | n, t=1 | #n is the notes list, t is the duration between notes defaulting to 1
play_pattern_timed n,t
end
melody scale(:c4,:major) #equivalent to play_pattern scale(:c4,:major)
melody scale(:c4,:major),0.2 #equivalent to play_pattern_timed scale(:c4,:major),0.2
Personally I write my own play routine and send arrays of notes and arrays of duration to this routine, which also allows me to specify the sustain value of each note as required. You can see the technique in many of my programs at https://gist.github.com/rbnpi
The beauty of Sonic Pi is that as it is written in ruby it is very flexible.
You are right though that the names are a bit confusing. I can remember being confused when I first use the earliest version of Sonic Pi by these names.
I definitely think we need to look beyond the play_pattern* Fns which were written to support a class back in day 1 of Sonic Pi. I think they're bad on many levels.
I think we should really think hard about the base abstraction and the sugar Fns on top. I think we should try and find a nice balance between your idea here, @xavriley's recent commit, Tidal and your work in Overtone land.
Ideally we have a very expressive data structure representing pattern and means to generate, manipulate and play them.
I notice that @xavriley has an outstanding pull request for a play_melody. I agree that we should do some careful thinking about it.
@rbnpi - I did almost exactly as you suggest. :-)
I raise this in order to make the API as obvious as possible for newcomers; it's not a blocker to my enjoyment of Sonic Pi.
Late to the party, but quite interested in this very issue... Any movement on this front?
Was looking for a way to play "licks" by scale degree. A search for "play_pattern_timed" brought me here. My "issue" is less about naming than about redefining these Fns or defining a similar Fn to make it easier to play melodically. In this respect, the advice from @rbnpi is useful. But also intrigued by those comments @samaaron made about the legacy support implied in those Fns. So, any update would be interesting. (Will probably search for more info about this within other issues, but it's probably useful to merge all "play_*" ideas within one thread.)
I'm aware that @xavriley is still interested in working on this kind of patterning stuff. It's also important to point out the existence of Petal which is a mini-Tidal-like DSL that sits on top of Sonic Pi - https://github.com/siaflab/petal
I really think we should be spending more time thinking about having something like this integrated into the language - its time has come :-)
Most helpful comment
I'm aware that @xavriley is still interested in working on this kind of patterning stuff. It's also important to point out the existence of Petal which is a mini-Tidal-like DSL that sits on top of Sonic Pi - https://github.com/siaflab/petal
I really think we should be spending more time thinking about having something like this integrated into the language - its time has come :-)