Examples#
The following examples are in the public domain (CC 0). Feel free to copy and modify them.
Create MIDI track with notes#
;;; Create MIDI track with notes
(use-modules (audio track)
(audio midi-note)
(audio midi-region)
(audio position)
(audio tracklist)
(project)
(zrythm))
(let* ((prj (zrythm-get-project))
(tracklist (project-get-tracklist prj))
(track-slot 3)
(track (midi-track-new track-slot "my midi track"))
(r-start-pos (position-new 1 1 1 0 0))
(r-end-pos (position-new 4 1 1 0 0))
(region (midi-region-new r-start-pos r-end-pos track-slot 0 0))
(mn-start-pos (position-new 2 1 1 0 0))
(mn-end-pos (position-new 3 1 1 0 0))
(note (midi-note-new region mn-start-pos mn-end-pos 80 90)))
(for-each
(lambda (pitch)
(let ((note (midi-note-new region mn-start-pos mn-end-pos pitch 90)))
(midi-region-add-midi-note region note)))
'(56 60 63))
(tracklist-insert-track tracklist track
track-slot)
(track-add-lane-region track region 0))
Hello world#
;;; Hello world
(display "Hello, World!")
Print all tracks#
;;; Print all tracks
;;;
;;; This is an example GNU Guile script using modules provided by Zrythm.
;;; See https://www.gnu.org/software/guile/ for more info about GNU Guile.
;;; See https://manual.zrythm.org/en/scripting/intro.html for more info
;;; about scripting in Zrythm.
(use-modules (audio track)
(audio tracklist)
(project)
(zrythm))
(let* ((prj (zrythm-get-project))
(tracklist (project-get-tracklist prj))
(num-tracks (tracklist-get-num-tracks tracklist)))
(let loop ((i 0))
(when (< i num-tracks)
(let ((track (tracklist-get-track-at-pos tracklist i)))
(display (track-get-name track))
(newline))
(loop (+ i 1)))))