On this page:
2.1 Definition Forms
2.1.1 Defining Oneshots
let
2.1.2 Defining Tracks
track
2.2 Note Functions
2.2.1 Loading Notes
load
2.2.2 Note Manipulation
reverse
pitch
stretch
resample
set-chop
2.3 Export Expressions
play!
save!
8.17.0.1

2 Reference🔗ℹ

This is a reference of all features currently available in Tuplet. As a quick reminder, a "oneshot" is either a note, tuplet, pattern, or polyrhythm.

2.1 Definition Forms🔗ℹ
2.1.1 Defining Oneshots🔗ℹ

syntax

(let name-or-pattern let-binding-expr)

 
name-or-pattern = id
  | pattern
     
let-binding-expr = oneshot
  | call-notefn
     
oneshot = id
  | tuplet
  | pattern
  | polyrhythm
     
tuplet = (beats oneshot ...)
     
pattern = (oneshot ...+)
     
polyrhythm = (: pattern ...+)
     
call-notefn = (notefn args ...)
     
notefn = load
  | pitch
  | stretch
  | reverse
  | resample
  | set-chop
 
  beats : positive-rational?
Bind value of oneshot-or-notefn to name, allowing you to use the provided name in a track, or another let expression.

If pattern binding, the chop? flag on the resulting notes will always be set to #t. To change a note’s chop? flag to #f, use set-chop.

2.1.2 Defining Tracks🔗ℹ

syntax

(track name bpm measure ...+)

 
name = id
     
measure = tuplet
     
oneshot = id
  | tuplet
  | pattern
  | polyrhythm
     
tuplet = (beats oneshot ...)
     
pattern = (oneshot ...+)
     
polyrhythm = (: pattern ...+)
 
  bpm : positive-rational?
  beats : positive-rational?
Create a track with the given bpm and measures, and bind it to name.

2.2 Note Functions🔗ℹ
2.2.1 Loading Notes🔗ℹ

procedure

(load filepath    
  [#:in in    
  #:out out    
  #:chop? chop?])  note?
  filepath : path-string?
  in : (or/c nonnegative-integer? false?) = #f
  out : (or/c nonnegative-integer? false?) = #f
  chop? : boolean? = #t
Loads a WAV file from the specified path.

The path is relative to the current file, which means "." and ".." can be used to represent the current folder and the parent folder, respectively.

If in/out points are provided, the audio is clipped from the beginning/end by that number of samples (yes, samples). Any in/out points set to #f default to the beginning/end of the clip, respectively.

The chop? argument defines whether to allow clips to play over each other, or extend into otherwise silent parts, such as during empty tuplets or once the track is over. Setting this to false is not recommended, and is very prone to audio peaking and clipping.

Note 1: Some programs (such as FL Studio) export a WAV file that rsound, the audio library used by Tuplet, has trouble reading.

Note 2: By default, rsound resamples and remixes audio to 2-channel stereo with a 44.1kHz sample rate. Be aware of this limitation when working with Tuplet.

2.2.2 Note Manipulation🔗ℹ

All of these functions result in a copy of the input note that can be bound. The original note will remain unchanged.

procedure

(reverse note)  note?

  note : note?
Reverses the input note, preserving stereo channels.

procedure

(pitch note semitones [cents])  note?

  note : note?
  semitones : rational?
  cents : rational? = 0
Pitches up note by the given semitones and cents. This function preserves the tempo of the clip.

Note: ffmpeg must be installed, on PATH, and compiled with librubberband for use of this function. For more information, refer to the README.md file.

procedure

(stretch note factor)  note?

  note : note?
  factor : positive-rational?
Stretches the input note by multiplying the speed by the given factor. This function preserves the pitch of the clip.

Note: ffmpeg must be installed, on PATH, and compiled with librubberband for use of this function. For more information, refer to the README.md file.

procedure

(resample note factor)  note?

  note : note?
  factor : positive-rational?
Resamples the input note by multiplying the speed by the given factor. The pitch of the clip will also be changed by the given factor.

procedure

(set-chop note chop?)  note?

  note : note?
  chop? : boolean?
Sets the chop? flag on a copy of a note. For more information on the chop? flag, see the documentation for load.

2.3 Export Expressions🔗ℹ

procedure

(play! track ...)  void?

  track : track-assembly?
Play the given track(s) on the default audio device. If multiple are provided, each track’s volume is divided by the number of tracks, to prevent clipping. Note that since this is a linear operation, the perceived volume of multiple tracks will be significantly quieter.

procedure

(save! track [filepath])  void?

  track : track-assembly?
  filepath : path-string? = "./"
Save the given track to a file. If the given filepath is a folder, save a WAV file in that folder, named with the track’s name. Else, save directly to the given filepath. The filepath defaults to the current directory.

This function will always try to overwrite the file at filepath, if one already exists.