TuningFork.SonicPi.Blocks (TuningFork v0.1.11)

Copy Markdown View Source

The words of TuningFork.SonicPi that take a block, as functions taking a fn.

Summary

Functions

Run fun once for each of times, each time beats from now, alongside the thread.

Run fun count times at count times the tempo, so the passes fit the time one took.

The first round of a loop: delay seconds of silence when there is a delay, else the round itself.

Run fun alongside: it starts now and the thread's own time does not move.

Start fun as loop name on a stage, worked out again every time round.

Start fun as a loop named loop_N, the way live_loop/3 does.

Run fun as one round of a loop and give the score it played.

The settings a loop started inside thread inherits: tempo, synth, defaults, transposition and open effects.

Run fun count times, passing which pass it is from zero when it takes an argument.

Run fun at bpm, then go back to the tempo before.

Run fun with everything it plays going through effect name with opts.

Run fun with the generator seeded from seed, then carry on from where it was.

Run fun with synth as the synth, then go back to the one before.

Run fun with opts as the synth defaults, then go back.

Run fun transposed by semitones, then go back.

Functions

at(times, args, fun)

@spec at([number()] | number(), [term()], (-> term()) | (term() -> term())) :: :ok

Run fun once for each of times, each time beats from now, alongside the thread.

density(count, fun)

@spec density(pos_integer(), (-> term())) :: :ok

Run fun count times at count times the tempo, so the passes fit the time one took.

first_round(fun, inherited, delay)

@spec first_round((-> term()), map(), number()) ::
  {:ok, TuningFork.Score.t()} | {:error, String.t()}

The first round of a loop: delay seconds of silence when there is a delay, else the round itself.

in_thread(fun)

@spec in_thread((-> term())) :: :ok

Run fun alongside: it starts now and the thread's own time does not move.

live_loop(name, opts, fun)

@spec live_loop(atom(), keyword(), (-> term())) ::
  :ok | {:error, String.t()} | :collected

Start fun as loop name on a stage, worked out again every time round.

:ok once it is started, or {:error, message} when the first round will not run. Inside TuningFork.SonicPi.run/1 the loop is collected instead and :collected is returned. opts may name a :stage, default TuningFork.Stage.

loop(fun)

@spec loop((-> term())) :: :ok | {:error, String.t()} | :collected

Start fun as a loop named loop_N, the way live_loop/3 does.

run_round(fun, inherited \\ %{})

@spec run_round((-> term()), map()) ::
  {:ok, TuningFork.Score.t()} | {:error, String.t()}

Run fun as one round of a loop and give the score it played.

{:ok, score} in seconds at 60 bpm, as long as the round's sleeps. {:error, message} when the round never slept, was waiting on a sync, or returned something that is neither a TuningFork.Part nor a TuningFork.Score while playing nothing. A round that returns a part or a score gives that instead.

settings(thread)

@spec settings(TuningFork.SonicPi.Thread.t()) :: map()

The settings a loop started inside thread inherits: tempo, synth, defaults, transposition and open effects.

times(count, fun)

@spec times(non_neg_integer(), (-> term()) | (non_neg_integer() -> term())) :: :ok

Run fun count times, passing which pass it is from zero when it takes an argument.

with_bpm(bpm, fun)

@spec with_bpm(number(), (-> result)) :: result when result: term()

Run fun at bpm, then go back to the tempo before.

with_fx(name, opts, fun)

@spec with_fx(
  atom(),
  keyword(),
  (-> term()) | (TuningFork.SonicPi.Handle.t() -> term())
) :: term()

Run fun with everything it plays going through effect name with opts.

fun may take the effect's TuningFork.SonicPi.Handle, for TuningFork.SonicPi.control/2.

with_random_seed(seed, fun)

@spec with_random_seed(term(), (-> result)) :: result when result: term()

Run fun with the generator seeded from seed, then carry on from where it was.

with_synth(synth, fun)

@spec with_synth(atom() | TuningFork.Voice.t(), (-> result)) :: result
when result: term()

Run fun with synth as the synth, then go back to the one before.

with_synth_defaults(opts, fun)

@spec with_synth_defaults(keyword(), (-> result)) :: result when result: term()

Run fun with opts as the synth defaults, then go back.

with_transpose(semitones, fun)

@spec with_transpose(integer(), (-> result)) :: result when result: term()

Run fun transposed by semitones, then go back.