Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/tsg/load tests #27

Merged
merged 8 commits into from
Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@
*.sch-bak
*.kicad_pcb-bak

# build directories and binaries
firmware/build
firmware/tests/build
firmware/tests/TapeLooper_gtest
dsp/tests/build
dsp/tests/TapeLooperDSP_gtest
plugin/build

# macOS crap
.DS_Store
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": false,
"debugServerArgs": "-f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/stm32h7x.cfg -c init -c \"reset init\"",
"debugServerArgs": "-f interface/stlink.cfg -f target/stm32h7x.cfg -c init -c \"reset init\"",
"serverLaunchTimeout": 20000,
"filterStderr": true,
"filterStdout": false,
"serverStarted": "target halted due to debug-request, current mode: Thread",
"preLaunchTask": "build-TapeLooper-debug",
"preLaunchTask": "build firmware",
"setupCommands": [
{ "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false },
{ "text": "-file-exec-and-symbols ${workspaceRoot}/build/TapeLooper.elf", "description": "load file", "ignoreFailures": false},
{ "text": "-file-exec-and-symbols ${workspaceRoot}/firmware/build/TapeLooper.elf", "description": "load file", "ignoreFailures": false},
{ "text": "-interpreter-exec console \"monitor endian little\"", "ignoreFailures": false },
{ "text": "-interpreter-exec console \"monitor reset\"", "ignoreFailures": false },
{ "text": "-interpreter-exec console \"monitor halt\"", "ignoreFailures": false },
Expand All @@ -40,7 +40,7 @@
},
"osx": {
"MIMode": "gdb",
"MIDebuggerPath": "/Users/johannes/dev/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gdb",
"MIDebuggerPath": "/Users/johanneselliesen/dev/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gdb",
"debugServerPath": "openocd"
},
"windows": {
Expand Down
4 changes: 4 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"TOOLCHAIN_PREFIX=\"${env:HOME}/dev/gcc-arm-none-eabi-9-2020-q2-update\"",
"-D",
"CMAKE_TOOLCHAIN_FILE=\"${workspaceRoot}/lib/libDaisy/cmake/toolchains/stm32h750xx.cmake\"",
"-D",
"CMAKE_BUILD_TYPE=RelWithDebInfo",
"-S",
"firmware",
"-B",
Expand All @@ -39,6 +41,8 @@
"TOOLCHAIN_PREFIX=\\\"C:/Program Files (x86)/GNU Arm Embedded Toolchain/9 2020-q2-update\\\"",
"-D",
"CMAKE_TOOLCHAIN_FILE=\\\"${workspaceRoot}/lib/libDaisy/cmake/toolchains/stm32h750xx.cmake\\\"",
"-D",
"CMAKE_BUILD_TYPE=RelWithDebInfo",
"-S",
"firmware",
"-B",
Expand Down
2 changes: 1 addition & 1 deletion dsp/src/dsp/AudioBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AudioBufferPtr

AudioBufferPtr<numChannels, FloatType> subBlock(size_t startSample, size_t length = size_t(-1)) const
{
const auto resultMaxLength = std::max(size_ - startSample, 0ul);
const auto resultMaxLength = std::max(size_ - startSample, size_t(0));
const auto resultLength = std::min(resultMaxLength, length);
AudioBufferPtr<numChannels, FloatType> result(resultLength);
for (size_t ch = 0; ch < numChannels; ch++)
Expand Down
27 changes: 5 additions & 22 deletions dsp/src/dsp/EmphasisEq.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ class FixedOnePoleShelvingEq

/**
* An pre-emphasis / de-emphasis EQ consisting of
* a first order high shelf and low shelf EQ.
* The pre-emphasis section boosts bass and treble,
* while the de-emphasis section cuts them by the same amount.
* two first order low shelf EQs.
* The pre-emphasis section boosts bass,
* while the de-emphasis section cuts it by the same amount.
*/
template <typename FloatType, int sampleRate>
class EmphasisEq
Expand All @@ -140,55 +140,38 @@ class EmphasisEq
void reset()
{
lowShelfPreEmphasis_.reset();
highShelfPreEmphasis_.reset();
lowShelfDeEmphasis_.reset();
highShelfDeEmphasis_.reset();
}

/** Boosts bass and treble by 12dB */
/** Boosts bass by 12dB */
MANUAL_INLINE FloatType processPreEmphasis(const FloatType inputSample)
{
FloatType sample = inputSample;
sample = lowShelfPreEmphasis_.processSample(sample);
sample = highShelfPreEmphasis_.processSample(sample);
return sample;
}

/** Cuts bass and treble by 12dB */
/** Cuts bass by 12dB */
MANUAL_INLINE FloatType processDeEmphasis(const FloatType inputSample)
{
FloatType sample = inputSample;
sample = lowShelfDeEmphasis_.processSample(sample);
sample = highShelfDeEmphasis_.processSample(sample);
return sample;
}

private:
static constexpr int lowFrequencyInHz_ = 500;
static constexpr int highFrequencyInHz_ = 2000;
static constexpr int gainInDecibels_ = 12;
FixedOnePoleShelvingEq<FixedOnePoleShelvingEqParameters<FloatType,
sampleRate,
OnePoleShelvingEqType::lowShelf,
lowFrequencyInHz_,
gainInDecibels_>>
lowShelfPreEmphasis_;
FixedOnePoleShelvingEq<FixedOnePoleShelvingEqParameters<FloatType,
sampleRate,
OnePoleShelvingEqType::highShelf,
highFrequencyInHz_,
gainInDecibels_>>
highShelfPreEmphasis_;
FixedOnePoleShelvingEq<FixedOnePoleShelvingEqParameters<FloatType,
sampleRate,
OnePoleShelvingEqType::lowShelf,
lowFrequencyInHz_,
-gainInDecibels_>>
lowShelfDeEmphasis_;
FixedOnePoleShelvingEq<FixedOnePoleShelvingEqParameters<FloatType,
sampleRate,
OnePoleShelvingEqType::highShelf,
highFrequencyInHz_,
-gainInDecibels_>>
highShelfDeEmphasis_;
};
9 changes: 1 addition & 8 deletions dsp/src/dsp/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class Player
{
processor_.reset();
speedModulator_.reset();
preGainSmoother_.reset(0);
postGainSmoother_.reset(0);
speedSmoother_.reset(0);
playbackLength_ = 0;
Expand Down Expand Up @@ -69,18 +68,14 @@ class Player
void process(float paramSpeed,
float speedModulationAmt,
Direction direction,
float paramPreProcessorGain,
float paramPostProcessorGain,
const typename ProcessorType::Parameters& processorParameters,
AudioBufferPtr<numChannels, float> outputToAddTo,
ExponentialSmoother::TimeConstant preGainSmootherTimeConstant =
ExponentialSmoother::TimeConstant(0.05f, sampleRateHz, 1),
ExponentialSmoother::TimeConstant postGainSmootherTimeConstant =
ExponentialSmoother::TimeConstant(0.05f, sampleRateHz, 1),
ExponentialSmoother::TimeConstant speedSmootherTimeConstant =
ExponentialSmoother::TimeConstant(0.5f, sampleRateHz, 1))
{
const auto preGainTarget = paramPreProcessorGain;
const auto postGainTarget = (isPlaying_) ? paramPostProcessorGain : 0.0f;
const auto speedTarget = limit(paramSpeed, minSpeed_, maxSpeed_);

Expand All @@ -89,7 +84,6 @@ class Player

for (size_t i = 0; i < outputToAddTo.size_; i++)
{
const auto preGain = preGainSmoother_.smooth(preGainTarget, preGainSmootherTimeConstant);
const auto postGain = postGainSmoother_.smooth(postGainTarget, postGainSmootherTimeConstant);
const auto speedModulation = speedModulator_.getAndAdvance() * speedModulationAmt;
const auto speed = speedModulation + speedSmoother_.smooth(speedTarget, speedSmootherTimeConstant);
Expand All @@ -114,7 +108,7 @@ class Player
for (size_t ch = 0; ch < numChannels; ch++)
{
interpolationBuffer_[1][ch] = interpolationBuffer_[0][ch];
interpolationBuffer_[0][ch] = sampleBuffer_[ch][indexToRead] * preGain;
interpolationBuffer_[0][ch] = sampleBuffer_[ch][indexToRead];
}
processor_.process(interpolationBuffer_[0].data(), processorParameters);
}
Expand Down Expand Up @@ -156,7 +150,6 @@ class Player
return value;
}

ExponentialSmoother preGainSmoother_;
ExponentialSmoother postGainSmoother_;
ExponentialSmoother speedSmoother_;

Expand Down
2 changes: 1 addition & 1 deletion dsp/src/dsp/TapeGrain.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ClockedNoiseGenerator
FloatType getCurrentOutputValue() const { return currentOutputValue_; }

private:
void updatePhaseIncrement(FloatType frequency)
MANUAL_INLINE void updatePhaseIncrement(FloatType frequency)
{
phaseIncrement_ = frequency / FloatType(sampleRate);
}
Expand Down
6 changes: 2 additions & 4 deletions dsp/src/dsp/TapeLooper.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class LooperStorage : public LooperStoragePtr<numChannels>
for (size_t ch = 0; ch < numChannels; ch++)
{
storage_[ch].fill(0.0f);
this->data[ch] = storage_[ch];
this->data[ch] = storage_[ch].data();
}
this->numSamples = size;
}
Expand Down Expand Up @@ -100,7 +100,6 @@ class TapeLooper
float wowAndFlutterAmt,
Direction direction,
const typename ProcessorType::Parameters& processorParameters,
float paramPreGain,
float paramPostGain,
AudioBufferPtr<numChannels, const float> input,
AudioBufferPtr<numChannels, float> outputToAddTo)
Expand All @@ -109,7 +108,6 @@ class TapeLooper
player_.process(paramSpeed,
mappedWowAndFlutterAmt * maxWowAndFlutterAmt_,
direction,
paramPreGain,
paramPostGain,
processorParameters,
outputToAddTo);
Expand Down Expand Up @@ -177,7 +175,7 @@ class TapeLooper
const LooperStoragePtr<numChannels> getSampleStoragePtr() const { return storage_; }

private:
static constexpr float maxWowAndFlutterAmt_ = 0.0125f;
static constexpr float maxWowAndFlutterAmt_ = 0.025f;
const LooperStoragePtr<numChannels> storage_;
LooperState state_;
PlayerType player_;
Expand Down
1 change: 1 addition & 0 deletions dsp/src/util/Memory.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <memory>
#include <cstring>

/**
* Represents a fixed size chunk of memory to which data can be written.
Expand Down
Loading