From ebde14e11dc6896367121801520602f8781d4561 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Mon, 12 Sep 2022 21:40:37 +0200 Subject: [PATCH] Fixes. --- UI.hpp | 10 +- config.h | 2 + .../TeensyVariablePlayback/src/playresmp.h | 148 +++++++++--------- 3 files changed, 84 insertions(+), 76 deletions(-) diff --git a/UI.hpp b/UI.hpp index 6121fc7..61b659d 100644 --- a/UI.hpp +++ b/UI.hpp @@ -6778,7 +6778,10 @@ void display_bar_float(const char* title, float value, float factor, int32_t min // Value display.setCursor(LCD_cols - size, 1); - display_float(value * factor, size_number, size_fraction, zeros, false, sign); // TBD + //display_float(value * factor, size_number, size_fraction, zeros, false, sign); // does not work with "Smallest code" optimizer + char s[LCD_cols + 1]; + snprintf_P(s, strlen(s), PSTR("%+1.1f"), value * factor); // not so good solution, but works with optimizer + display.print(s); // Bar display.setCursor(0, 1); @@ -6833,7 +6836,10 @@ void display_meter_float(const char* title, float value, float factor, float off // Value display.setCursor(LCD_cols - size, 1); - display_float((value + offset) * factor, size_number, size_fraction, zeros, false, sign); + //display_float((value + offset) * factor, size_number, size_fraction, zeros, false, sign); // does not work with "Smallest code" optimizer + char s[LCD_cols + 1]; + snprintf_P(s, strlen(s), PSTR("%+1.1f"), (value + offset) * factor); // not so good solution, but works with optimizer + display.print(s); // Bar display.setCursor(0, 1); diff --git a/config.h b/config.h index e7fb539..b69a2d0 100644 --- a/config.h +++ b/config.h @@ -53,6 +53,8 @@ // sed -i.orig 's/^#define USB_MIDI_SYSEX_MAX 290/#define USB_MIDI_SYSEX_MAX 4104/' /usr/local/arduino-teensy/hardware/teensy/avr/cores/teensy3/usb_midi.h // sed -i.orig 's/^#define USB_MIDI_SYSEX_MAX 290/#define USB_MIDI_SYSEX_MAX 4104/' /usr/local/arduino-teensy/hardware/teensy/avr/cores/teensy4/usb_midi.h //#define USB_MIDI_SYSEX_MAX 4104 +// +// Information about memory layout, etc.: https://www.pjrc.com/store/teensy41.html #define VERSION "1.2.3" diff --git a/third-party/TeensyVariablePlayback/src/playresmp.h b/third-party/TeensyVariablePlayback/src/playresmp.h index fd2f617..984c5c8 100644 --- a/third-party/TeensyVariablePlayback/src/playresmp.h +++ b/third-party/TeensyVariablePlayback/src/playresmp.h @@ -8,90 +8,90 @@ template class AudioPlayResmp : public AudioStream { -public: -AudioPlayResmp(): AudioStream(0, NULL), reader(nullptr) -{ -} + public: + AudioPlayResmp(): AudioStream(0, NULL), reader(nullptr) + { + } -virtual ~AudioPlayResmp() { -} + virtual ~AudioPlayResmp() { + } -void begin(void) -{ - reader->begin(); -} + void begin(void) + { + reader->begin(); + } -bool playRaw(const char *filename, uint16_t numChannels) -{ - stop(); - return reader->play(filename, false, numChannels); -} + bool playRaw(const char *filename, uint16_t numChannels) + { + stop(); + return reader->play(filename, false, numChannels); + } -bool playWav(const char *filename) -{ - stop(); - return reader->play(filename, true, 0); -} + bool playWav(const char *filename) + { + stop(); + return reader->play(filename, true, 0); + } + + bool playRaw(int16_t *data, uint32_t numSamples, uint16_t numChannels) + { + stop(); + return reader->playRaw(data, numSamples, numChannels); + } -bool playRaw(int16_t *data, uint32_t numSamples, uint16_t numChannels) -{ - stop(); - return reader->playRaw(data, numSamples, numChannels); -} + bool playRaw(const unsigned int *data, uint32_t numSamples, uint16_t numChannels) + { + return playRaw((int16_t *) data, numSamples, numChannels); + } -bool playRaw(const unsigned int *data, uint32_t numSamples, uint16_t numChannels) -{ - return playRaw((int16_t *) data, numSamples, numChannels); -} + bool playWav(int16_t *data, uint32_t fileSize) + { + stop(); + return reader->playWav(data, fileSize); + } -bool playWav(int16_t *data, uint32_t fileSize) -{ - stop(); - return reader->playWav(data, fileSize); -} - -bool playWav(const unsigned int *data, uint32_t fileSize) { - return playWav((int16_t *) data, fileSize); -} - -void setPlaybackRate(float f) { - reader->setPlaybackRate(f); -} - -void setLoopType(loop_type t) { - reader->setLoopType(t); -} - -void setLoopStart(uint32_t loop_start) { - reader->setLoopStart(loop_start); -} - -void setLoopFinish(uint32_t loop_finish) { - reader->setLoopFinish(loop_finish); -} - -void enableInterpolation(bool enable) { - if (enable) - reader->setInterpolationType(ResampleInterpolationType::resampleinterpolation_quadratic); - else - reader->setInterpolationType(ResampleInterpolationType::resampleinterpolation_none); -} - -bool isPlaying(void) { - return reader->isPlaying(); -}; + bool playWav(const unsigned int *data, uint32_t fileSize) { + return playWav((int16_t *) data, fileSize); + } -void stop() { - reader->stop(); -} + void setPlaybackRate(float f) { + reader->setPlaybackRate(f); + } -void update() -{ - int _numChannels = reader->getNumChannels(); - if (_numChannels == -1) - return; + void setLoopType(loop_type t) { + reader->setLoopType(t); + } + + void setLoopStart(uint32_t loop_start) { + reader->setLoopStart(loop_start); + } + + void setLoopFinish(uint32_t loop_finish) { + reader->setLoopFinish(loop_finish); + } + + void enableInterpolation(bool enable) { + if (enable) + reader->setInterpolationType(ResampleInterpolationType::resampleinterpolation_quadratic); + else + reader->setInterpolationType(ResampleInterpolationType::resampleinterpolation_none); + } + + bool isPlaying(void) { + return reader->isPlaying(); + }; + + void stop() { + reader->stop(); + } + + void update() + { + int _numChannels = reader->getNumChannels(); + if (_numChannels == -1) + return; - unsigned int n; + unsigned int n; audio_block_t *blocks[_numChannels]; int16_t *data[_numChannels]; // only update if we're playing