summaryrefslogtreecommitdiff
path: root/graphics/src/audio/program.rs
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/src/audio/program.rs')
-rw-r--r--graphics/src/audio/program.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/graphics/src/audio/program.rs b/graphics/src/audio/program.rs
index f31be06..91f0608 100644
--- a/graphics/src/audio/program.rs
+++ b/graphics/src/audio/program.rs
@@ -1,5 +1,5 @@
use crate::audio::{
- Channels,
+ AUDIO_FPS, Channels,
channel::{Channel, DutyCycle},
parse,
};
@@ -16,6 +16,7 @@ pub enum ChanSpec {
pub enum Instruction {
Pause,
Jump(usize),
+ Tempo(u32),
SetVolume(ChanSpec, u8),
SetPitch(ChanSpec, u8),
SetPulseDutyA(DutyCycle),
@@ -98,11 +99,14 @@ impl Program {
match ins {
I::Pause => {
// pause execution until next `exec` call
- self.pause = self.tempo / 60;
+ self.pause = (AUDIO_FPS * 4) / self.tempo.clamp(1, 240);
}
I::Jump(pc) => {
self.pc = pc;
}
+ I::Tempo(tempo) => {
+ self.tempo = tempo;
+ }
I::SetVolume(chan_spec, volume) => {
// set the volume (amplitude) on a given channel
use ChanSpec as C;