Skip to content

Commit edd6dcb

Browse files
authored
Merge pull request #51 from bkshepherd/new-gml-modules
New gml modules
2 parents bedc6ca + 9526039 commit edd6dcb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+11212
-98
lines changed

.gitmodules

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
[submodule "Software/GuitarPedal/DaisySP"]
2-
path = Software/GuitarPedal/DaisySP
3-
url = https://github.com/electro-smith/DaisySP.git
4-
[submodule "Software/GuitarPedal/libDaisy"]
5-
path = Software/GuitarPedal/libDaisy
6-
url = https://github.com/electro-smith/libDaisy.git
7-
[submodule "Software/GuitarPedal/infra"]
8-
path = Software/GuitarPedal/q/infra
9-
url = https://github.com/cycfi/infra.git
10-
[submodule "Software/GuitarPedal/q"]
11-
path = Software/GuitarPedal/q/q
12-
url = https://github.com/cycfi/q.git
1+
[submodule "Software/GuitarPedal/dependencies/DaisySP"]
2+
path = Software/GuitarPedal/dependencies/DaisySP
3+
url = https://github.com/electro-smith/DaisySP.git
4+
[submodule "Software/GuitarPedal/dependencies/libDaisy"]
5+
path = Software/GuitarPedal/dependencies/libDaisy
6+
url = https://github.com/electro-smith/libDaisy.git
7+
[submodule "Software/GuitarPedal/dependencies/infra"]
8+
path = Software/GuitarPedal/dependencies/q/infra
9+
url = https://github.com/cycfi/infra.git
10+
[submodule "Software/GuitarPedal/dependencies/q"]
11+
path = Software/GuitarPedal/dependencies/q/q
12+
url = https://github.com/cycfi/q.git
13+
[submodule "Software/GuitarPedal/dependencies/gcem"]
14+
path = Software/GuitarPedal/dependencies/gcem
15+
url = https://github.com/kthohr/gcem.git
16+
[submodule "Software/GuitarPedal/dependencies/RTNeural"]
17+
path = Software/GuitarPedal/dependencies/RTNeural
18+
url = https://github.com/jatinchowdhury18/RTNeural
19+
[submodule "Software/GuitarPedal/dependencies/eigen"]
20+
path = Software/GuitarPedal/dependencies/eigen
21+
url = https://gitlab.com/libeigen/eigen
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// ImpulseResponse.cpp
3+
// NeuralAmpModeler-macOS
4+
//
5+
// Created by Steven Atkinson on 12/30/22.
6+
//
7+
// Modified by Keith Bloemer on 12/28/23
8+
// Greatly simplified by assuming 1 channel, 1 input per Process call, and constant samplerate.
9+
// For initial investigation into running IR's on the Daisy Seed
10+
11+
#include "ImpulseResponse.h"
12+
13+
ImpulseResponse::ImpulseResponse() {}
14+
15+
// Destructor
16+
ImpulseResponse::~ImpulseResponse() {
17+
// No Code Needed
18+
}
19+
20+
void ImpulseResponse::Init(std::vector<float> irData) {
21+
mRawAudio = irData;
22+
_SetWeights();
23+
}
24+
25+
float ImpulseResponse::Process(float inputs) {
26+
27+
_UpdateHistory(inputs);
28+
29+
int j = mHistoryIndex - mHistoryRequired;
30+
auto input = Eigen::Map<const Eigen::VectorXf>(&mHistory[j], mHistoryRequired + 1);
31+
32+
_AdvanceHistoryIndex(1); // KAB MOD - for Daisy implementation numFrames is always 1
33+
34+
return (float)mWeight.dot(input);
35+
}
36+
37+
void ImpulseResponse::_SetWeights() {
38+
39+
const size_t irLength = std::min(mRawAudio.size(), mMaxLength);
40+
mWeight.resize(irLength);
41+
// Gain reduction.
42+
// https://github.com/sdatkinson/NeuralAmpModelerPlugin/issues/100#issuecomment-1455273839
43+
// Add sample rate-dependence
44+
// const float gain = pow(10, -18 * 0.05) * 48000 / mSampleRate; //KAB NOTE: This made a very bad/loud sound on Daisy Seed
45+
for (size_t i = 0, j = irLength - 1; i < irLength; i++, j--)
46+
// mWeight[j] = gain * mRawAudio[i];
47+
mWeight[j] = mRawAudio[i];
48+
mHistoryRequired = irLength - 1;
49+
50+
// Moved from HISTORY::EnsureHistorySize since only doing once for this module (assuming same size IR's)
51+
// TODO: Maybe find a more efficient method of indexing mHistory,
52+
// rather than copying the end of the vector (length of IR) back to the beginning all at once.
53+
const size_t requiredHistoryArraySize =
54+
5 * mHistoryRequired; // Just so we don't spend too much time copying back. // KAB NOTE: was 10 *
55+
mHistory.resize(requiredHistoryArraySize);
56+
std::fill(mHistory.begin(), mHistory.end(), 0.0f);
57+
mHistoryIndex = mHistoryRequired;
58+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// ImpulseResponse.h
3+
// NeuralAmpModeler-macOS
4+
//
5+
// Created by Steven Atkinson on 12/30/22.
6+
//
7+
// Impulse response processing
8+
//
9+
// Modified by Keith Bloemer on 12/28/23
10+
// Greatly simplified by assuming 1 channel, 1 input per Process call, and constant samplerate.
11+
// For initial investigation into running IR's on the Daisy Seed
12+
13+
#pragma once
14+
15+
#include "dsp.h"
16+
#include <Eigen/Dense>
17+
18+
class ImpulseResponse : public History {
19+
public:
20+
ImpulseResponse();
21+
~ImpulseResponse();
22+
23+
void Init(std::vector<float> irData);
24+
float Process(float inputs);
25+
26+
private:
27+
// Set the weights, given that the plugin is running at the provided sample
28+
// rate.
29+
void _SetWeights();
30+
31+
// State of audio
32+
// Keep a copy of the raw audio that was loaded so that it can be resampled
33+
std::vector<float> mRawAudio;
34+
float mRawAudioSampleRate;
35+
float mSampleRate;
36+
37+
const size_t mMaxLength = 8192;
38+
// The weights
39+
Eigen::VectorXf mWeight;
40+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* File: dsp.cpp
3+
* Created Date: March 17, 2023
4+
* Author: Steven Atkinson (steven@atkinson.mn)
5+
*/
6+
// Modified by Keith Bloemer on 12/28/23
7+
// Greatly simplified by assuming 1 channel, 1 input per Process call, and constant samplerate.
8+
// For initial investigation into running IR's on the Daisy Seed
9+
10+
#include "dsp.h"
11+
12+
History::History() {}
13+
14+
// Destructor
15+
History::~History() {
16+
// No Code Needed
17+
}
18+
19+
void History::_AdvanceHistoryIndex(const size_t bufferSize) { mHistoryIndex += bufferSize; }
20+
21+
void History::_RewindHistory() {
22+
// TODO memcpy? Should be fine w/ history array being >2x the history length.
23+
for (size_t i = 0, j = mHistoryIndex - mHistoryRequired; i < mHistoryRequired; i++, j++)
24+
mHistory[i] = mHistory[j];
25+
mHistoryIndex = mHistoryRequired;
26+
}
27+
28+
void History::_UpdateHistory(float inputs) {
29+
if (mHistoryIndex + 1 >= mHistory.size())
30+
_RewindHistory();
31+
32+
mHistory[mHistoryIndex] = inputs;
33+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#pragma once
2+
3+
#include <vector>
4+
5+
// A class where a longer buffer of history is needed to correctly calculate
6+
// the DSP algorithm (e.g. algorithms involving convolution).
7+
//
8+
// Hacky stuff:
9+
// * Mono
10+
// * Single-precision floats.
11+
class History {
12+
public:
13+
History();
14+
~History();
15+
16+
protected:
17+
// Called at the end of the DSP, advance the hsitory index to the next open
18+
// spot. Does not ensure that it's at a valid address.
19+
void _AdvanceHistoryIndex(const size_t bufferSize);
20+
// Drop the new samples into the history array.
21+
// Manages history array size
22+
void _UpdateHistory(float inputs);
23+
24+
// The history array that's used for DSP calculations.
25+
std::vector<float> mHistory;
26+
// How many samples previous are required.
27+
// Zero means that no history is required--only the current sample.
28+
size_t mHistoryRequired = 0;
29+
// Location of the first sample in the current buffer.
30+
// Shall always be in the range [mHistoryRequired, mHistory.size()).
31+
size_t mHistoryIndex = 0;
32+
33+
private:
34+
// Copy the end of the history back to the front and reset mHistoryIndex
35+
void _RewindHistory();
36+
};

0 commit comments

Comments
 (0)