From 00f30dd5c0c2121d8e2d968d0a260a5486c378a6 Mon Sep 17 00:00:00 2001 From: ashley Date: Thu, 24 Aug 2023 21:26:07 -0400 Subject: [PATCH] Play PCM samples in ESF stream --- src/reskit/soundtrack/engines/echo.rs | 47 ++++++++++++++++++--------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/src/reskit/soundtrack/engines/echo.rs b/src/reskit/soundtrack/engines/echo.rs index 9093e6f..3e6b789 100644 --- a/src/reskit/soundtrack/engines/echo.rs +++ b/src/reskit/soundtrack/engines/echo.rs @@ -82,6 +82,27 @@ fn get_semitone( note: &Note ) -> Result> { } ) } +/** + * Notes are used to index PCM sample playback. C = 1, etc. + */ +fn get_pcm_index( note: &Note ) -> Result> { + Ok( match note { + Note::NoteOff => return Err( "internal error: attempted to get pcm index for a Note::NoteOff" )?, + Note::C(_) => 0, + Note::CSharp(_) => 1, + Note::D(_) => 2, + Note::DSharp(_) => 3, + Note::E(_) => 4, + Note::F(_) => 5, + Note::FSharp(_) => 6, + Note::G(_) => 7, + Note::GSharp(_) => 8, + Note::A(_) => 9, + Note::ASharp(_) => 10, + Note::B(_) => 11 + } ) +} + /** Gets the semitone frequency used by Echo. https://github.com/sikthehedgehog/Echo/blob/master/doc/esf.txt#L243 @@ -235,23 +256,19 @@ fn get_events_for_channel( channel: &mut Channel, row: &PatternRow ) -> Result