From 8f3f380dedcb70afeb51ab13e294a95cd8faf31b Mon Sep 17 00:00:00 2001 From: d_m Date: Mon, 21 Aug 2023 23:23:29 -0400 Subject: [PATCH] synth demo --- mksite.sh | 2 +- synthdemo.tal | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 synthdemo.tal diff --git a/mksite.sh b/mksite.sh index d809a00..86941cc 100755 --- a/mksite.sh +++ b/mksite.sh @@ -14,7 +14,7 @@ for NAME in about.txt asma.rom math32.tal test-math32.tal test-math32.py \ wave.tal graph.tal arg.tal arg-demo.tal \ deck.tal cards.tal card-sprites.tal mask-sprites.tal \ testing.tal type-abc.tal tar.tal \ - audio.md audio.txt \ + audio.md audio.txt synthdemo.tal \ ; do echo "-> $NAME" cp $NAME /var/www/plastic-idolatry.com/html/erik/nxu diff --git a/synthdemo.tal b/synthdemo.tal new file mode 100644 index 0000000..7cd8736 --- /dev/null +++ b/synthdemo.tal @@ -0,0 +1,66 @@ +( synth demo using new device ) + +|30 @Audio [ + &vec $2 ( callback vector ) + &dur $2 ( duration in ms ) + &mode $1 ( mode -- currently articulation ) + &vol $1 ( L/R volume 0-f ) + &a $1 ( envelope: attack, 10ms resolution ) + &d $1 ( envelope: decay, 10ms resolution ) + &s $1 ( envelope: sustain, 10ms resolution ) + &r $1 ( envelope: release, 10ms resolution ) + &len $2 ( waveform data length in bytes ) + &addr $2 ( waveform data address ) + &detune $1 ( fractional semitone detune ) + &pitch $1 ( MIDI pitch to play ) +] + +|0000 + @step $2 + @tempo $2 + +|0100 + #00bb .tempo STZ2 + #ff .Audio/vol DEO + ;square .Audio/addr DEO2 + #0002 .Audio/len DEO2 + ;play .Audio/vec DEO2 +( #00 .Audio/mode DEO ) + #30 .Audio/mode DEO + #00 .Audio/a DEO + #01 .Audio/d DEO + #08 .Audio/s DEO + #08 .Audio/r DEO + ( fall-through ) + +@play + .tempo LDZ2 .Audio/dur DEO2 ( ; dur<-tempo ) + .step LDZ2k DUP2 ;notes ADD2 ( z^ step* notes+step* ) + LDA .Audio/pitch DEO ( z^ step* ; pitch<-p ) + INC2 DUP2 #0004 LTH2 ?&done ( z^ step+1* ) + POP2 #0000 ( z^ 0* ) + .tempo LDZ2k #0002 SUB2 ( z^ 0* zt^ tempo-2* ) + #ea60 OVR2 #0004 MUL2 DIV2 ( z^ 0* zt^ tempo-2* bpm* ) + emit-bpm ( z^ 0* zt^ tempo-2* ; emit bpm ) + ROT STZ2 ( z^ 0* ; zt<-tempo-2 ) + &done ROT STZ2 BRK ( ; z<-step' ) + +( @notes 21 21 22 23 ) +@notes 39 39 3b 3c + +@square ff 00 + +@emit-bpm ( bpm* -> ) + emit-dec2 #2018 DEO LIT "b #18 DEO LIT "p #18 DEO LIT "m #18 DEO #0a18 DEO JMP2r + +( emit a short as a decimal ) +@emit-dec2 ( n* -> ) + LITr 00 ( n [0] ) + &read ( n [k] ) + #000a DIV2k STH2k MUL2 SUB2 STH2r INCr ( n%10 n/10 [k+1] ) + DUP2 ORA ,&read JCN + POP2 ( top element was 0000 ) + &write ( n0 n1 ... nk [k+1] ) + NIP #30 ADD #18 DEO LITr 01 SUBr ( n0 ... n{k-1} [k] ) + STHkr ,&write JCN + POPr JMP2r