mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-03-25 21:30:44 +00:00
ReEewrite sequence playback to be fast enough to not pause during state
changes Hand edit a few tone values to sound better
This commit is contained in:
parent
fbbb72c369
commit
734de4a5e3
src/samplesrc/a2pwm
@ -4,6 +4,40 @@ const iobuffer = $1C00
|
|||||||
const NMACROS = 7
|
const NMACROS = 7
|
||||||
const FALSE = 0
|
const FALSE = 0
|
||||||
const TRUE = !FALSE
|
const TRUE = !FALSE
|
||||||
|
//
|
||||||
|
// Sequence values
|
||||||
|
//
|
||||||
|
const SEQ_MACRO = 0
|
||||||
|
const SEQ_NOTE = 7
|
||||||
|
const SEQ_LFO = 21
|
||||||
|
const SEQ_LFO_INC = 29
|
||||||
|
const SEQ_LFO_DEC = 30
|
||||||
|
const SEQ_OCT_INC = 31
|
||||||
|
const SEQ_OCT_DEC = 32
|
||||||
|
const SEQ_DUR_INC = 33
|
||||||
|
const SEQ_DUR_DEC = 34
|
||||||
|
const SEQ_REST = 35
|
||||||
|
//
|
||||||
|
// Predefine replay functions
|
||||||
|
//
|
||||||
|
predef playback, replaynote, replayrest
|
||||||
|
predef replaylfo, replaylfoinc, replaylfodec
|
||||||
|
predef replayoctinc, replayoctdec, replaydurinc, replaydurdec
|
||||||
|
//
|
||||||
|
// Replay function pointers
|
||||||
|
//
|
||||||
|
word replay[] = @playback, @playback, @playback, @playback, @playback, @playback
|
||||||
|
word = @playback
|
||||||
|
word = @replaynote, @replaynote, @replaynote, @replaynote, @replaynote, @replaynote
|
||||||
|
word = @replaynote, @replaynote, @replaynote, @replaynote, @replaynote, @replaynote
|
||||||
|
word = @replaynote, @replaynote
|
||||||
|
word = @replaylfo, @replaylfo, @replaylfo, @replaylfo, @replaylfo, @replaylfo
|
||||||
|
word = @replaylfo, @replaylfo
|
||||||
|
word = @replaylfoinc, @replaylfodec
|
||||||
|
word = @replayoctinc, @replayoctdec
|
||||||
|
word = @replaydurinc, @replaydurdec
|
||||||
|
word = @replayrest
|
||||||
|
|
||||||
//
|
//
|
||||||
// Patch state
|
// Patch state
|
||||||
//
|
//
|
||||||
@ -32,6 +66,7 @@ word macros // Pointer to macros
|
|||||||
byte record[t_macro] // Recording buffer
|
byte record[t_macro] // Recording buffer
|
||||||
word recording = FALSE // Recording key/flag
|
word recording = FALSE // Recording key/flag
|
||||||
byte playing = 0 // Keep track of active macros
|
byte playing = 0 // Keep track of active macros
|
||||||
|
byte recalc = FALSE // Recalc envelope flag
|
||||||
//
|
//
|
||||||
// System variables.
|
// System variables.
|
||||||
//
|
//
|
||||||
@ -260,23 +295,15 @@ def recalcEnv
|
|||||||
current:rateAtk = $0FFF/current.durAtk
|
current:rateAtk = $0FFF/current.durAtk
|
||||||
current:rateDcy = 0
|
current:rateDcy = 0
|
||||||
current:rateRel = $0FFF/current.durRel
|
current:rateRel = $0FFF/current.durRel
|
||||||
|
recalc = FALSE
|
||||||
|
return envelope(current.durAtk, current.durDcy, current.durSus, current.durRel, current:rateAtk, current:rateDcy, current:rateRel)
|
||||||
end
|
end
|
||||||
//
|
//
|
||||||
// Rest
|
// Playback a sequence
|
||||||
//
|
|
||||||
def restnote
|
|
||||||
byte d
|
|
||||||
|
|
||||||
for d = duration downto 1
|
|
||||||
call($FCA8, $6A, 0, 0, 0)
|
|
||||||
next
|
|
||||||
end
|
|
||||||
//
|
|
||||||
// playback a sequence
|
|
||||||
//
|
//
|
||||||
def playback(idx)
|
def playback(idx)
|
||||||
word macro
|
word macro
|
||||||
byte seq, key, i
|
byte seq, i
|
||||||
byte save[t_state]
|
byte save[t_state]
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -298,91 +325,14 @@ def playback(idx)
|
|||||||
memcpy(@current, macro + stateStart, t_state)
|
memcpy(@current, macro + stateStart, t_state)
|
||||||
duration = current.durAtk + current.durDcy + current.durSus + current.durRel
|
duration = current.durAtk + current.durDcy + current.durSus + current.durRel
|
||||||
envelope(current.durAtk, current.durDcy, current.durSus, current.durRel, current:rateAtk, current:rateDcy, current:rateRel)
|
envelope(current.durAtk, current.durDcy, current.durSus, current.durRel, current:rateAtk, current:rateDcy, current:rateRel)
|
||||||
|
recalc = FALSE
|
||||||
fin
|
fin
|
||||||
//
|
//
|
||||||
// Run throught the sequence
|
// Run throught the sequence
|
||||||
//
|
//
|
||||||
for seq = 1 to macro->sequence
|
for i = 1 to macro->sequence
|
||||||
key = macro->sequence[seq]
|
seq = macro->sequence[i]
|
||||||
//
|
(replay[seq])(seq)
|
||||||
// Check for tone keys
|
|
||||||
//
|
|
||||||
for i = 0 to 13
|
|
||||||
if keytone[i] == key
|
|
||||||
if current.LFO == 0
|
|
||||||
hilopwm(scale.[current.octave, i], 0, 0)
|
|
||||||
else
|
|
||||||
hilopwm(scale.[current.octave, i], current.LFO, current.idxLFO)
|
|
||||||
fin
|
|
||||||
break
|
|
||||||
fin
|
|
||||||
next
|
|
||||||
//
|
|
||||||
// Check for macro keys
|
|
||||||
//
|
|
||||||
if i > 13
|
|
||||||
for i = 0 to 6
|
|
||||||
if keymacro[i] == key
|
|
||||||
playback(i)
|
|
||||||
break
|
|
||||||
fin
|
|
||||||
next
|
|
||||||
if i > 6
|
|
||||||
when key
|
|
||||||
is ' '
|
|
||||||
restnote
|
|
||||||
break
|
|
||||||
is $15 // ->
|
|
||||||
if current.octave < 3
|
|
||||||
current.octave++
|
|
||||||
fin
|
|
||||||
break
|
|
||||||
is $08 // <-
|
|
||||||
if current.octave > 0
|
|
||||||
current.octave--
|
|
||||||
fin
|
|
||||||
break
|
|
||||||
is '1'
|
|
||||||
is '2'
|
|
||||||
is '3'
|
|
||||||
is '4'
|
|
||||||
is '5'
|
|
||||||
is '6'
|
|
||||||
is '7'
|
|
||||||
is '8'
|
|
||||||
current.idxLFO = key - '1'
|
|
||||||
break
|
|
||||||
is '<'
|
|
||||||
is ','
|
|
||||||
if current.LFO > 0
|
|
||||||
current.LFO--
|
|
||||||
fin
|
|
||||||
break
|
|
||||||
is '>'
|
|
||||||
is '.'
|
|
||||||
if current.LFO < 32
|
|
||||||
current.LFO++
|
|
||||||
fin
|
|
||||||
break
|
|
||||||
is '+'
|
|
||||||
is $0B // UP
|
|
||||||
if duration < 40
|
|
||||||
duration++
|
|
||||||
fin
|
|
||||||
recalcEnv
|
|
||||||
envelope(current.durAtk, current.durDcy, current.durSus, current.durRel, current:rateAtk, current:rateDcy, current:rateRel)
|
|
||||||
break
|
|
||||||
is '-'
|
|
||||||
is $0A // DOWN
|
|
||||||
if duration > 1
|
|
||||||
duration--
|
|
||||||
fin
|
|
||||||
recalcEnv
|
|
||||||
envelope(current.durAtk, current.durDcy, current.durSus, current.durRel, current:rateAtk, current:rateDcy, current:rateRel)
|
|
||||||
break
|
|
||||||
wend
|
|
||||||
fin
|
|
||||||
fin
|
|
||||||
next
|
next
|
||||||
//
|
//
|
||||||
// Restore state
|
// Restore state
|
||||||
@ -391,17 +341,87 @@ def playback(idx)
|
|||||||
duration = current.durAtk + current.durDcy + current.durSus + current.durRel
|
duration = current.durAtk + current.durDcy + current.durSus + current.durRel
|
||||||
envelope(current.durAtk, current.durDcy, current.durSus, current.durRel, current:rateAtk, current:rateDcy, current:rateRel)
|
envelope(current.durAtk, current.durDcy, current.durSus, current.durRel, current:rateAtk, current:rateDcy, current:rateRel)
|
||||||
playing = playing & ~(1 << idx)
|
playing = playing & ~(1 << idx)
|
||||||
|
return recalcEnv
|
||||||
|
end
|
||||||
|
//
|
||||||
|
// Replay rest
|
||||||
|
//
|
||||||
|
def replayrest(idx)
|
||||||
|
byte d
|
||||||
|
|
||||||
|
for d = duration downto 1
|
||||||
|
call($FCA8, $6A, 0, 0, 0)
|
||||||
|
next
|
||||||
|
end
|
||||||
|
//
|
||||||
|
// Replay note
|
||||||
|
//
|
||||||
|
def replaynote(idx)
|
||||||
|
if recalc
|
||||||
|
recalcEnv
|
||||||
|
fin
|
||||||
|
if current.LFO == 0
|
||||||
|
hilopwm(scale.[current.octave, idx - SEQ_NOTE], 0, 0)
|
||||||
|
else
|
||||||
|
hilopwm(scale.[current.octave, idx - SEQ_NOTE], current.LFO, current.idxLFO)
|
||||||
|
fin
|
||||||
|
end
|
||||||
|
//
|
||||||
|
// Replay duration
|
||||||
|
//
|
||||||
|
def replaydurinc(idx)
|
||||||
|
if duration < 40
|
||||||
|
duration++
|
||||||
|
recalc = TRUE;
|
||||||
|
fin
|
||||||
|
end
|
||||||
|
def replaydurdec(idx)
|
||||||
|
if duration > 1
|
||||||
|
duration--
|
||||||
|
recalc = TRUE;
|
||||||
|
fin
|
||||||
|
end
|
||||||
|
//
|
||||||
|
// Replay octave
|
||||||
|
//
|
||||||
|
def replayoctinc(idx)
|
||||||
|
if current.octave < 3
|
||||||
|
current.octave++
|
||||||
|
fin
|
||||||
|
end
|
||||||
|
def replayoctdec(idx)
|
||||||
|
if current.octave > 0
|
||||||
|
current.octave--
|
||||||
|
fin
|
||||||
|
end
|
||||||
|
//
|
||||||
|
// Replay LFO
|
||||||
|
//
|
||||||
|
def replaylfoinc(idx)
|
||||||
|
if current.LFO > 0
|
||||||
|
current.LFO--
|
||||||
|
fin
|
||||||
|
end
|
||||||
|
def replaylfodec(idx)
|
||||||
|
if current.LFO < 32
|
||||||
|
current.LFO++
|
||||||
|
fin
|
||||||
|
end
|
||||||
|
def replaylfo(idx)
|
||||||
|
current.idxLFO = idx - SEQ_LFO
|
||||||
end
|
end
|
||||||
//
|
//
|
||||||
// Main loop
|
// Main loop
|
||||||
//
|
//
|
||||||
def main
|
def main
|
||||||
byte quit, key, i
|
byte quit, key, i
|
||||||
|
word seq
|
||||||
|
|
||||||
quit = FALSE
|
quit = FALSE
|
||||||
repeat
|
repeat
|
||||||
if keypressed
|
if keypressed
|
||||||
key = toupper(getc)
|
key = toupper(getc)
|
||||||
|
seq = -1
|
||||||
//
|
//
|
||||||
// Check for tone keys
|
// Check for tone keys
|
||||||
//
|
//
|
||||||
@ -412,6 +432,7 @@ def main
|
|||||||
else
|
else
|
||||||
hilopwm(scale.[current.octave, i], current.LFO, current.idxLFO)
|
hilopwm(scale.[current.octave, i], current.LFO, current.idxLFO)
|
||||||
fin
|
fin
|
||||||
|
seq = SEQ_NOTE + i
|
||||||
break
|
break
|
||||||
fin
|
fin
|
||||||
next
|
next
|
||||||
@ -422,6 +443,7 @@ def main
|
|||||||
for i = 0 to 6
|
for i = 0 to 6
|
||||||
if keymacro[i] == key
|
if keymacro[i] == key
|
||||||
playback(i)
|
playback(i)
|
||||||
|
seq = SEQ_MACRO + i
|
||||||
break
|
break
|
||||||
fin
|
fin
|
||||||
next
|
next
|
||||||
@ -439,7 +461,6 @@ def main
|
|||||||
normal
|
normal
|
||||||
putsxy(29, 3, "RECORDING")
|
putsxy(29, 3, "RECORDING")
|
||||||
inverse
|
inverse
|
||||||
key = 0
|
|
||||||
break
|
break
|
||||||
fin
|
fin
|
||||||
next
|
next
|
||||||
@ -473,21 +494,36 @@ def main
|
|||||||
putsxy(29, 3, " ")
|
putsxy(29, 3, " ")
|
||||||
fin
|
fin
|
||||||
break
|
break
|
||||||
|
is $0B // UP
|
||||||
|
if duration < 40
|
||||||
|
duration++
|
||||||
|
recalcEnv
|
||||||
|
showDuration
|
||||||
|
fin
|
||||||
|
seq = SEQ_DUR_INC
|
||||||
|
break
|
||||||
|
is '-'
|
||||||
|
is $0A // DOWN
|
||||||
|
if duration > 1
|
||||||
|
duration--
|
||||||
|
recalcEnv
|
||||||
|
showDuration
|
||||||
|
fin
|
||||||
|
seq = SEQ_DUR_DEC
|
||||||
|
break
|
||||||
is $15 // ->
|
is $15 // ->
|
||||||
if current.octave < 3
|
if current.octave < 3
|
||||||
current.octave++
|
current.octave++
|
||||||
showOctave
|
showOctave
|
||||||
else
|
|
||||||
key = 0
|
|
||||||
fin
|
fin
|
||||||
|
seq = SEQ_OCT_INC
|
||||||
break
|
break
|
||||||
is $08 // <-
|
is $08 // <-
|
||||||
if current.octave > 0
|
if current.octave > 0
|
||||||
current.octave--
|
current.octave--
|
||||||
showOctave
|
showOctave
|
||||||
else
|
|
||||||
key = 0
|
|
||||||
fin
|
fin
|
||||||
|
seq = SEQ_OCT_DEC
|
||||||
break
|
break
|
||||||
is '1'
|
is '1'
|
||||||
is '2'
|
is '2'
|
||||||
@ -499,13 +535,7 @@ def main
|
|||||||
is '8'
|
is '8'
|
||||||
current.idxLFO = key - '1'
|
current.idxLFO = key - '1'
|
||||||
showWaveform
|
showWaveform
|
||||||
break
|
seq = SEQ_LFO + current.idxLFO
|
||||||
is '<'
|
|
||||||
is ','
|
|
||||||
if current.LFO > 0
|
|
||||||
current.LFO--
|
|
||||||
fin
|
|
||||||
showLFO
|
|
||||||
break
|
break
|
||||||
is '>'
|
is '>'
|
||||||
is '.'
|
is '.'
|
||||||
@ -513,45 +543,33 @@ def main
|
|||||||
current.LFO++
|
current.LFO++
|
||||||
fin
|
fin
|
||||||
showLFO
|
showLFO
|
||||||
|
seq = SEQ_LFO_INC
|
||||||
|
break
|
||||||
|
is '<'
|
||||||
|
is ','
|
||||||
|
if current.LFO > 0
|
||||||
|
current.LFO--
|
||||||
|
fin
|
||||||
|
showLFO
|
||||||
|
seq = SEQ_LFO_DEC
|
||||||
break
|
break
|
||||||
is '+'
|
is '+'
|
||||||
is $0B // UP
|
|
||||||
if duration < 40
|
|
||||||
duration++
|
|
||||||
recalcEnv
|
|
||||||
envelope(current.durAtk, current.durDcy, current.durSus, current.durRel, current:rateAtk, current:rateDcy, current:rateRel)
|
|
||||||
showDuration
|
|
||||||
else
|
|
||||||
key = 0
|
|
||||||
fin
|
|
||||||
break
|
|
||||||
is '-'
|
|
||||||
is $0A // DOWN
|
|
||||||
if duration > 1
|
|
||||||
duration--
|
|
||||||
recalcEnv
|
|
||||||
envelope(current.durAtk, current.durDcy, current.durSus, current.durRel, current:rateAtk, current:rateDcy, current:rateRel)
|
|
||||||
showDuration
|
|
||||||
else
|
|
||||||
key = 0
|
|
||||||
fin
|
|
||||||
break
|
|
||||||
is 'P'
|
is 'P'
|
||||||
if modPatch
|
if modPatch
|
||||||
savePatch
|
savePatch
|
||||||
fin
|
fin
|
||||||
break
|
break
|
||||||
is '0' // Toggle speaker phase
|
is '0' // Toggle speaker phase
|
||||||
^$C030
|
^$C030
|
||||||
break
|
break
|
||||||
wend
|
wend
|
||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
if recording and key
|
if recording and seq >= 0
|
||||||
if record.sequence < 255
|
if record.sequence < 255
|
||||||
record.sequence++
|
record.sequence++
|
||||||
record.sequence[record.sequence] = key
|
record.sequence[record.sequence] = seq
|
||||||
else
|
else
|
||||||
beep
|
beep
|
||||||
fin
|
fin
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user