* WAVEing at Repetitive :PROPERTIES: :type: title :author: Zachary Kanfer :END: Repetitive Repetitive Music * Bored at home ** "Antistress" app [[file:~/Downloads/antistress-main3.jpg][zp-image]] * I want more! ** faster! slower! ** more beats! ** undo! ** different scales! * Enter: Emacs :PROPERTIES: :type: title :END: * WAVE files? ** [[https://assets.rebelmouse.io/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbWFnZSI6Imh0dHBzOi8vbWVkaWEucmJsLm1zL2ltYWdlP3U9JTJGZmlsZXMlMkYyMDE2JTJGMDUlMkYwOCUyRjYzNTk4MzI4MzA0MDc1OTE5NS04MDIyMzc0OTlfbWljaGFlbC1waGVscHMuanBnJmhvPWh0dHBzJTNBJTJGJTJGYXo2MTY1Nzgudm8ubXNlY25kLm5ldCZzPTQ0MiZoPTZlZTQwYzVhNmI0ZWFjNjBlMzA0MzVkMTFjYTFkNTRiZjkzYjNmM2ZhNmQ3Y2ZkNGQzOWVhODZiODUzODdiYjMmc2l6ZT05ODB4JmM9ODc4MzU2MDM2IiwiZXhwaXJlc19hdCI6MTY1MjM4MjU5Mn0.xIvOCNadJObm8X6TRtOQM_GcIbpdxBhRTgfUpoWS03w/img.jpg?width=1200&height=628][zp-image]] * WAVE -- a musical file format * WAVE -- an :slide: annoying file format ** one-byte numbers are unsigned integers :slide: ** two-byte numbers are signed integers :slide: * WAVE -- an annoying file format II ** little-endian by default! ((0 1) == 10) :slide: ** The WAVE spec allows big-endian as well. :slide: But... ** Emacs can only play little-endian data. :slide: * WAVE -- an :slide: annoying file format III: duplicate data ** SAMPLE-RATE ** NUMBER-OF-CHANNELS (1: mono, 2: stereo) ** BITS-PER-SAMPLE :slide: ** BLOCK-ALIGN: number-of-channels * bits-per-sample / 8 :slide: ** BYTE-RATE: sample-rate * number-of-channels * bits-per-sample / 8 :slide: * WAVE -- an annoying file format IV ** Last part of the file is "data". :slide: ** "The actual sound data". :slide: * What is data? ** [[https://i.ytimg.com/vi/9FqFm_vmVnE/maxresdefault.jpg][zp-image]] * Data! ** Turns out it's the height of the waveform at each sample. ** [[https://upload.wikimedia.org/wikipedia/commons/b/bf/Pcm.svg][zp-image]] * Demo! :PROPERTIES: :type: title :END: * Other features :slide: ** Save to a file! :slide: *** Had to make "silent" notes, which are not normally needed. :slide: ** Different scales! :slide: ** Terrible-sounding keyboard support * Things I learned: Emacs :PROPERTIES: :type: title :END: * Emacs has buttons! ** (insert-text-button "text") * Spacing issues! :slide: ** Unicode has a "zero-width space"! Yay! :slide: ** It has width! Boo. * Ways to play sound...that don't work! :slide: ** #'play-sound... :slide: *** blocks :slide: ** Async.el... :slide: *** is silent * A way to play sound...that works! :slide: ** Shell out to native WAVE player :slide: ** ...once. * Side effects have a big impact on runtime. :PROPERTIES: :type: title :END: * Thing I learned: Music Theory :PROPERTIES: :type: title :END: * Music theory is NOT easily programmable. :PROPERTIES: :type: title :END: * Scale degrees ** [[https://hellomusictheory.com/wp-content/uploads/2019/02/10.8-1024x180.png][zp-image]] * You don't want to program in scale degrees. :PROPERTIES: :type: title :END: * Scale degrees ** [[https://hellomusictheory.com/wp-content/uploads/2019/02/10.8-1024x180.png][zp-image]] * Intervals ** [[https://chordprogressionblog.files.wordpress.com/2016/09/intervals1.gif][zp-image]] * You don't want to program in intervals. :PROPERTIES: :type: title :END: * Intervals ** [[https://chordprogressionblog.files.wordpress.com/2016/09/intervals1.gif][zp-image]] * Music is really frequencies. :PROPERTIES: :type: title :END: * Solution! ** At a low-level, use frequencies. :slide: ** At a high level, use "semitones up from the root". Translate these to frequencies. * Future work ** drums ** interactive keyboard ** add overtones (harmonics) * Thank you! ** [[https://zck.org/emacsconf2020][https://zck.org/emacsconf2020]] ** [[https://emacsnyc.org/][https://emacsnyc.org]] ** [[mailto:zkanfer@gmail.com][zkanfer@gmail.com]]