Created
December 10, 2017 03:59
-
-
Save ethancrawford/79fb4a5a76c892aa74dae000e801e29f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; This is a WIP attempt to create a wavetable synth in overtone. | |
;; No useful hints were found when searching for ways to read a | |
;; .wavetable file (such as those found in the Sonic Pi repo at | |
;; https://github.com/samaaron/sonic-pi/tree/master/etc/wavetables/AKWF | |
;; into memory and use this with the osc ugen. | |
;; An attempt was made here to pass the data of a buffer into the | |
;; (signal->wavetable ...) fn and pass the output of this into the | |
;; osc ugen, but this results in a buffer overflow error. | |
(ns sonic-pi.synths.basic | |
(:use [overtone.live]) | |
(:require [sonic-pi.synths.core :as core])) | |
(def b (buffer-alloc-read "/home/ethan/repos/sonic-pi/etc/wavetables/AKWF/AKWF_0001/AKWF_0001.wav")) | |
(without-namespace-in-synthdef | |
(defsynth sonic-pi-wavetable [note 52 | |
note_slide 0 | |
note_slide_shape 1 | |
note_slide_curve 0 | |
amp 1 | |
amp_slide 0 | |
amp_slide_shape 1 | |
amp_slide_curve 0 | |
pan 0 | |
pan_slide 0 | |
pan_slide_shape 1 | |
pan_slide_curve 0 | |
attack 0 | |
decay 0 | |
sustain 0 | |
release 1 | |
attack_level 1 | |
decay_level -1 | |
sustain_level 1 | |
env_curve 1 | |
out_bus 0] | |
(let [decay_level (select:kr (= -1 decay_level) [decay_level sustain_level]) | |
note (varlag note note_slide note_slide_curve note_slide_shape) | |
amp (varlag amp amp_slide amp_slide_curve amp_slide_shape) | |
amp-fudge 1 | |
pan (varlag pan pan_slide pan_slide_curve pan_slide_shape) | |
freq (midicps note) | |
data (buffer-data b) | |
wave (signal->wavetable data) | |
snd (osc wave freq) | |
env (env-gen:kr (core/shaped-adsr attack decay sustain release attack_level decay_level sustain_level env_curve) :action FREE) | |
] | |
(out out_bus (pan2 (* amp-fudge env snd) pan amp))))) | |
(core/save-synthdef sonic-pi-wavetable) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment