Skip to content
5 changes: 5 additions & 0 deletions AudioProcessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ class AudioProcessor {
}
}

void setGains(float gainL, float gainR) {
ampA.gain(gainL);
ampB.gain(gainR);
}

void setA(std::unique_ptr<Plugin>& pin, float gain = 1.0) {
if (!pin) return;
AudioNoInterrupts();
Expand Down
29 changes: 29 additions & 0 deletions AudioStreamCustom.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// AudioStreamCustom: Base class for plugins that implement per-sample DSP
// instead of using the Teensy Audio Library's AudioConnection graph.
//
// Subclasses implement fillBlock() to generate 128 samples of audio.
// The Teensy audio engine calls update() automatically at block rate,
// which allocates a block, calls fillBlock(), and transmits the result.

#pragma once

#include <Audio.h>

class AudioStreamCustom : public AudioStream {
public:
AudioStreamCustom() : AudioStream(0, NULL) {}
virtual ~AudioStreamCustom() {}

// Subclass implements this: fill block->data[0..AUDIO_BLOCK_SAMPLES-1]
// with int16_t samples. Called once per audio block (~2.9ms at 44.1kHz).
virtual void fillBlock(audio_block_t *block) = 0;

void update() override {
audio_block_t *block = allocate();
if (block) {
fillBlock(block);
transmit(block);
release(block);
}
}
};
73 changes: 50 additions & 23 deletions Banks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ int Bank::getSize() {
return size;
}

//test plugging
#include "P_TestPlugin.hpp"

//Bank A:
#include "P_radioOhNo.hpp"
#include "P_Rwalk_SineFMFlange.hpp"
Expand Down Expand Up @@ -84,35 +81,65 @@ int Bank::getSize() {
#include "P_Rwalk_BitCrushPW.hpp"
#include "P_Rwalk_LFree.hpp"

//Maybe Later: (Unused or incomplet)

#include "P_Rwalk_SineFM.hpp"
#include "P_VarWave.hpp"
#include "P_RwalkVarWave.hpp"
#include "P_Rwalk_ModWave.hpp"
#include "P_Rwalk_WaveTwist.hpp"
#include "P_Rwalk_LBit.hpp"
#include "P_delayPonzo.hpp"


#include "P_TestPlugin.hpp" // hidden test mode (10s button hold)

//Experimental: excluded from compilation to save flash space.
//To re-enable, uncomment and add to a bank definition in Banks_Def.hpp.
//#include "P_Rwalk_SineFM.hpp"
//#include "P_VarWave.hpp"
//#include "P_RwalkVarWave.hpp"
//#include "P_Rwalk_ModWave.hpp"
//#include "P_Rwalk_WaveTwist.hpp"
//#include "P_Rwalk_LBit.hpp"
//#include "P_delayPonzo.hpp"

//Bank D: Resonant Bodies
#include "P_CombNoise.hpp"
#include "P_PluckCloud.hpp"
#include "P_TubeResonance.hpp"
#include "P_FormantNoise.hpp"
#include "P_BowedMetal.hpp"
#include "P_FlangeNoise.hpp"
#include "P_NoiseBells.hpp"
#include "P_NoiseHarmonics.hpp"
#include "P_IceRain.hpp"
#include "P_DroneBody.hpp"

//Bank E: Chaos Machines
#include "P_LogisticNoise.hpp"
#include "P_HenonDust.hpp"
#include "P_CellularSynth.hpp"
#include "P_StochasticPulse.hpp"
#include "P_BitShift.hpp"
#include "P_FeedbackFM.hpp"
#include "P_RunawayFilter.hpp"
#include "P_GlitchLoop.hpp"
#include "P_SubHarmonic.hpp"
#include "P_DualAttractor.hpp"

//Bank F: Stochastic
#include "P_PulseWander.hpp"
#include "P_TwinPulse.hpp"
#include "P_QuantPulse.hpp"
#include "P_ShapedPulse.hpp"
#include "P_ShiftPulse.hpp"
#include "P_MetallicNoise.hpp"
#include "P_NoiseSlew.hpp"
#include "P_NoiseBurst.hpp"
#include "P_LFSRNoise.hpp"
#include "P_DualPulse.hpp"


static const Bank bank1 BANKS_DEF_1; // Banks_Def.hpp
static const Bank bank2 BANKS_DEF_2;
static const Bank bank3 BANKS_DEF_3;
static const Bank bank4 BANKS_DEF_4;
static const Bank bank5 BANKS_DEF_5;
static std::array<Bank, numBanks> banks { bank1, bank2, bank3, bank4, bank5 };

// static const Bank bank6 BANKS_DEF_6;
// static const Bank bank7 BANKS_DEF_7;
// static const Bank bank8 BANKS_DEF_8;
// static const Bank bank9 BANKS_DEF_9;
// static const Bank bank10 BANKS_DEF_10;
// static std::array<Bank, programsPerBank> banks { bank1, bank2, bank3, bank4, bank5, bank6, bank7, bank8, bank9, bank10 };
static const Bank bank6 BANKS_DEF_6;
static std::array<Bank, numBanks> banks { bank1, bank2, bank3, bank4, bank5, bank6 };

Bank& getBankForIndex(int i) {
if (i < 0) i = 0;
if (i >= programsPerBank) i = (programsPerBank - 1);
if (i >= numBanks) i = (numBanks - 1);
return banks[i];
}
2 changes: 1 addition & 1 deletion Banks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <memory>

static const int programsPerBank = 10;
static const int numBanks = 5;
static const int numBanks = 6;

struct Bank {

Expand Down
44 changes: 37 additions & 7 deletions Banks_Def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,41 @@
{ "Rwalk_LFree", 1.0 } \
}

#define BANKS_DEF_4
#define BANKS_DEF_5
#define BANKS_DEF_4 { \
{ "CombNoise", 1.0 }, \
{ "PluckCloud", 1.0 }, \
{ "TubeResonance", 1.0 }, \
{ "FormantNoise", 1.0 }, \
{ "BowedMetal", 1.0 }, \
{ "FlangeNoise", 1.0 }, \
{ "NoiseBells", 0.8 }, \
{ "NoiseHarmonics", 1.0 }, \
{ "IceRain", 1.0 }, \
{ "DroneBody", 1.0 } \
}

#define BANKS_DEF_5 { \
{ "LogisticNoise", 1.0 }, \
{ "HenonDust", 1.0 }, \
{ "CellularSynth", 1.0 }, \
{ "StochasticPulse", 1.0 }, \
{ "BitShift", 1.0 }, \
{ "FeedbackFM", 1.0 }, \
{ "RunawayFilter", 1.0 }, \
{ "GlitchLoop", 1.0 }, \
{ "SubHarmonic", 1.0 }, \
{ "DualAttractor", 1.0 } \
}

// #define BANKS_DEF_6
// #define BANKS_DEF_7
// #define BANKS_DEF_8
// #define BANKS_DEF_9
// #define BANKS_DEF_10
#define BANKS_DEF_6 { \
{ "PulseWander", 1.0 }, \
{ "TwinPulse", 1.0 }, \
{ "QuantPulse", 1.0 }, \
{ "ShapedPulse", 1.0 }, \
{ "ShiftPulse", 1.0 }, \
{ "MetallicNoise", 1.0 }, \
{ "NoiseSlew", 1.0 }, \
{ "NoiseBurst", 1.0 }, \
{ "LFSRNoise", 1.0 }, \
{ "DualPulse", 1.0 } \
}
76 changes: 76 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Noise Plethora Firmware — Build & Flash
# Requires: arduino-cli, teensy:avr core, patched AudioStream files
#
# Usage:
# make — compile firmware
# make upload — compile + flash to connected Teensy
# make clean — remove build artifacts
# make port — show available serial ports

FQBN := teensy:avr:teensy40
SKETCH_DIR := /tmp/Noise_Plethora
SRC_DIR := $(shell pwd)
PORT ?= $(shell arduino-cli board list 2>/dev/null | grep -i "teensy\|usb" | awk '{print $$1}' | head -1)
TEENSY_CORE := $(shell find $(HOME)/Library/Arduino15/packages/teensy/hardware/avr -maxdepth 1 -type d 2>/dev/null | tail -1)

.PHONY: all compile upload clean port patch setup

all: compile

setup: patch
@echo "Setup complete. Run 'make' to compile."

patch:
@if [ -z "$(TEENSY_CORE)" ]; then \
echo "ERROR: Teensy core not found. Run first:"; \
echo " arduino-cli config add board_manager.additional_urls https://www.pjrc.com/teensy/package_teensy_index.json"; \
echo " arduino-cli core update-index && arduino-cli core install teensy:avr"; \
exit 1; \
fi
@echo "Patching Teensy AudioStream at $(TEENSY_CORE)..."
@cp "$(TEENSY_CORE)/cores/teensy4/AudioStream.h" "$(TEENSY_CORE)/cores/teensy4/AudioStream.h.bak" 2>/dev/null || true
@cp "$(TEENSY_CORE)/cores/teensy4/AudioStream.cpp" "$(TEENSY_CORE)/cores/teensy4/AudioStream.cpp.bak" 2>/dev/null || true
@cp teensy/avr/cores/teensy4/AudioStream.h "$(TEENSY_CORE)/cores/teensy4/"
@cp teensy/avr/cores/teensy4/AudioStream.cpp "$(TEENSY_CORE)/cores/teensy4/"
@DELAY=$$(find "$(TEENSY_CORE)" -name "effect_delay.h" -path "*/Audio/*" | head -1); \
if [ -n "$$DELAY" ]; then \
cp "$$DELAY" "$${DELAY}.bak" 2>/dev/null || true; \
cp teensy/avr/libraries/Audio/effect_delay.h "$$DELAY"; \
echo "Patched: AudioStream.h, AudioStream.cpp, effect_delay.h"; \
else \
echo "Patched: AudioStream.h, AudioStream.cpp (effect_delay.h not found)"; \
fi
@echo "Originals backed up with .bak extension."

unpatch:
@if [ -z "$(TEENSY_CORE)" ]; then echo "Teensy core not found."; exit 1; fi
@echo "Restoring original Teensy AudioStream..."
@cd "$(TEENSY_CORE)/cores/teensy4" && \
[ -f AudioStream.h.bak ] && mv AudioStream.h.bak AudioStream.h && \
[ -f AudioStream.cpp.bak ] && mv AudioStream.cpp.bak AudioStream.cpp || true
@DELAY=$$(find "$(TEENSY_CORE)" -name "effect_delay.h.bak" -path "*/Audio/*" | head -1); \
if [ -n "$$DELAY" ]; then mv "$$DELAY" "$${DELAY%.bak}"; fi
@echo "Originals restored."

compile:
@echo "Copying source to $(SKETCH_DIR) (Arduino requires dir name = sketch name)..."
@rm -rf $(SKETCH_DIR)
@cp -r $(SRC_DIR) $(SKETCH_DIR)
@echo "Compiling for Teensy 4.0..."
arduino-cli compile --fqbn $(FQBN) $(SKETCH_DIR)

upload: compile
@if [ -z "$(PORT)" ]; then \
echo "ERROR: No Teensy found. Connect via USB and try again."; \
echo "Available ports:"; \
arduino-cli board list; \
exit 1; \
fi
@echo "Flashing to $(PORT)..."
arduino-cli upload --fqbn $(FQBN) --port $(PORT) $(SKETCH_DIR)

clean:
rm -rf $(SKETCH_DIR)

port:
arduino-cli board list
Loading