Skip to content

Instantly share code, notes, and snippets.

@matchaxnb
Last active August 4, 2025 15:04
Show Gist options
  • Select an option

  • Save matchaxnb/14b631d27dab8f956ab47a4249aee2dc to your computer and use it in GitHub Desktop.

Select an option

Save matchaxnb/14b631d27dab8f956ab47a4249aee2dc to your computer and use it in GitHub Desktop.

Revisions

  1. matchaxnb revised this gist Aug 4, 2025. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion Utilities for Sapf (sound as pure form)
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,8 @@ toHz ; we convert it
    [62 nnhz .3 0 pulsesin .3 mum 64 nnhz .3 0 pulsesin .3 mum] cyc $/ play

    ; play a sequence (just d7 chord followed by M7 chord)
    stop clear [[[d7 M7] @ 220 *] flat @ \pch[[(pch 0 sinosc .2 T) (.1 mum)] $/ ] ! [.3 mum] ] $/ $/ cyc play
    stop clear [[[d7 M7] @ 220 *] flat @ \pch[[(pch 0 sinosc .2 T) (.1 mum)] $/ ] ! [.3 mum] ] $/ $/ cyc play

    ; sequencing (the second part is note length)
    stop clear [[[d7 M7] @ 220 * ] flat] @ @ [1 8 irand 8 / 1/8 2/8 1/8 1/4 1/8 1/8 1/2 1/4] \pch dur[[(pch 0 sinosc dur
    T) (.1 mum)] $/ ] ! $/ $/ $/ cyc play
  2. matchaxnb revised this gist Aug 4, 2025. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion Utilities for Sapf (sound as pure form)
    Original file line number Diff line number Diff line change
    @@ -11,4 +11,7 @@ toHz ; we convert it
    ] = midiToHz

    ; just play a major second between D and E
    [62 nnhz .3 0 pulsesin .3 mum 64 nnhz .3 0 pulsesin .3 mum] cyc $/ play
    [62 nnhz .3 0 pulsesin .3 mum 64 nnhz .3 0 pulsesin .3 mum] cyc $/ play

    ; play a sequence (just d7 chord followed by M7 chord)
    stop clear [[[d7 M7] @ 220 *] flat @ \pch[[(pch 0 sinosc .2 T) (.1 mum)] $/ ] ! [.3 mum] ] $/ $/ cyc play
  3. matchaxnb revised this gist Aug 4, 2025. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion Utilities for Sapf (sound as pure form)
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,7 @@
    midinum 60 - ; this is the distance to C4
    1/12 * C4 + ; this is the pitch log index for the note
    toHz ; we convert it
    ] = midiToHz
    ] = midiToHz

    ; just play a major second between D and E
    [62 nnhz .3 0 pulsesin .3 mum 64 nnhz .3 0 pulsesin .3 mum] cyc $/ play
  4. matchaxnb created this gist Aug 4, 2025.
    11 changes: 11 additions & 0 deletions Utilities for Sapf (sound as pure form)
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    ; i'll update this from time to time
    ; add this to your prelude file
    ; i am under the assumption that you keep the original prelude contents

    \pitchLogIndex [ pitchLogIndex 2^ ] = toHz
    \midinum [
    ; first produce a pitch log index based on C4==60
    midinum 60 - ; this is the distance to C4
    1/12 * C4 + ; this is the pitch log index for the note
    toHz ; we convert it
    ] = midiToHz