diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-11-22 00:12:34 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-11-22 00:12:34 -0500 |
| commit | 696ab0aadc346f1046f35419a558c291097c521f (patch) | |
| tree | 765e4486310a8968fca5b71570eb023fe44b1644 /graphics/src/audio/program.rs | |
| parent | audio: create orchestration system (diff) | |
| download | DungeonCrawl-696ab0aadc346f1046f35419a558c291097c521f.tar.gz DungeonCrawl-696ab0aadc346f1046f35419a558c291097c521f.tar.bz2 DungeonCrawl-696ab0aadc346f1046f35419a558c291097c521f.zip | |
audio: add temp changing
Diffstat (limited to '')
| -rw-r--r-- | graphics/src/audio/program.rs | 8 |
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; |