9.0
top
← prev up next →

Sonic Pi: WORK IN PROGRESSπŸ”— i

John Clements <clements@racket-lang.org>

This package is a collection of functions and a very primitive language level that follows the lead of Sonic Pi. Specifically, (like Sonic Pi) it uses scsynth as its sound generation engine, and creates the same network of units that Sonic Pi does.

This is very much a work in progress. I’m releasing it as a project so that others can try it out and steal parts of it.

Want to try it out? Install the package, then open "lsonic-example.rkt" in DrRacket and click Run.

Tell me what happens!

1 An Imperative InterfaceπŸ”— i

One thing that I don’t like that much about Sonic Pi is its unabashedly imperative interface.
However, underneath what I hope will be a nice clean language (lsonic), I’m also going to publish the lower-level imperative interface. For one thing, it’s pretty obvious what it’ll look like: it’ll look like Sonic Pi. That means less design work. Here are some functions:

procedure

( startup)context?

Starts an scsynth, returns a context that can be used to ... well, to create a job context.

procedure

( start-jobctxt)job-context?

ctxt:context?
Given a context, starts a job, and return a handle for that job. A job corresponds to a “piece of music.”

procedure

( end-jobjob-ctxt)void?

job-ctxt:job-context?
Ends a job: fades out the job and cancels all scheduled notes associated with the job.

procedure

( play-notejob-ctxtnotetime)void?

job-ctxt:job-context?
note:note?
Play note using job-ctxt, at time time, specified in inexact milliseconds since the epoch. If the time value is less than the current number of milliseconds since the epoch, the note will be played immediately. (Note that this means that you can always specify 0.0 to play a note immediately.)

procedure

( notesynth-namenote-numparam-part...)note?

synth-name:string?
note-num:real?
param-part:(or string? real? )
Creates a note. In addition to the synth-name and note-num (represented as a MIDI note number), users may specify non-default values for one of many other parameters using and interleaved parameter-name / value style. For instance:

(note"saw"78"attack"0.5"amp"0.5)

Here’s the full list of parameters and their defaults:
'((note_slide0)
(note_slide_shape5)
(node_slide_curve0)
(amp1)
(amp_slide0)
(amp_slide_shape5)
(pan0)
(pan_slide0)
(pan_slide_shape5)
(pan_slide_curve0)
(attack0)
(decay0)
(sustain0)
(release1)
(attack_level1)
(sustain_level1)
(env_curve2)
(out_bus12.0))

procedure

( note?note)boolean?

note:any/c
returns true for notes.

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /