Reorganization of the library layout

master
Steve Lascos 6 years ago
parent dc63f9871e
commit 90441b5668
  1. 3
      examples/BA1_TGA_Pro_demo/BA1_TGA_Pro_demo.ino
  2. 3
      examples/BA2_TGA_Pro_1MEM/BA2_TGA_Pro_1MEM.ino
  3. 3
      examples/BA3_TGA_Pro_2MEM/BA3_TGA_Pro_2MEM.ino
  4. 3
      examples/BA4_TGA_Pro_delay_reverb/BA4_TGA_Pro_delay_reverb.ino
  5. 3
      examples/BA5_TGA_Pro_ExternalDelay_demo/BA5_TGA_Pro_ExternalDelay_demo.ino
  6. 3
      examples/Delay/AnalogDelayDemo/AnalogDelayDemo.ino
  7. 14
      src/AudioEffectAnalogDelay.h
  8. 12
      src/AudioEffectSOS.h
  9. 10
      src/BAAudioControlWM8731.h
  10. 18
      src/BAAudioEffectDelayExternal.h
  11. 10
      src/BAGpio.h
  12. 10
      src/BAHardware.h
  13. 28
      src/BASpiMemory.h
  14. 10
      src/BATypes.h
  15. 12
      src/LibBasicFunctions.h
  16. 18
      src/LibMemoryManagement.h
  17. 2
      src/common/AudioDelay.cpp
  18. 2
      src/common/AudioHelpers.cpp
  19. 2
      src/common/ExtMemSlot.cpp
  20. 14
      src/common/ExternalSramManager.cpp
  21. 2
      src/common/IirBiquadFilter.cpp
  22. 2
      src/common/ParameterAutomation.cpp
  23. 4
      src/effects/AudioEffectAnalogDelay.cpp
  24. 2
      src/effects/AudioEffectAnalogDelayFilters.h
  25. 1
      src/effects/AudioEffectSOS.cpp
  26. 8
      src/effects/BAAudioEffectDelayExternal.cpp
  27. 4
      src/peripherals/BAAudioControlWM8731.cpp
  28. 4
      src/peripherals/BAGpio.cpp
  29. 4
      src/peripherals/BASpiMemory.cpp

@ -21,7 +21,8 @@ using namespace midi;
//#define ENABLE_MEM_TEST // uncomment this line and 'Save As' to a new location to test the SPI memory //#define ENABLE_MEM_TEST // uncomment this line and 'Save As' to a new location to test the SPI memory
using namespace BAGuitar; using namespace BALibrary;
using namespace BAEffects;
AudioInputI2S i2sIn; AudioInputI2S i2sIn;
AudioOutputI2S i2sOut; AudioOutputI2S i2sOut;

@ -23,7 +23,8 @@
MIDI_CREATE_DEFAULT_INSTANCE(); MIDI_CREATE_DEFAULT_INSTANCE();
using namespace midi; using namespace midi;
using namespace BAGuitar; using namespace BALibrary;
using namespace BAEffects;
AudioInputI2S i2sIn; AudioInputI2S i2sIn;
AudioOutputI2S i2sOut; AudioOutputI2S i2sOut;

@ -24,7 +24,8 @@
MIDI_CREATE_DEFAULT_INSTANCE(); MIDI_CREATE_DEFAULT_INSTANCE();
using namespace midi; using namespace midi;
using namespace BAGuitar; using namespace BAEffects;
using namespace BALibrary;
AudioInputI2S i2sIn; AudioInputI2S i2sIn;
AudioOutputI2S i2sOut; AudioOutputI2S i2sOut;

@ -14,7 +14,8 @@
#include <MIDI.h> #include <MIDI.h>
#include "BAGuitar.h" #include "BAGuitar.h"
using namespace BAGuitar; using namespace BAEffects;
using namespace BALibrary;
BAAudioControlWM8731 codecControl; BAAudioControlWM8731 codecControl;

@ -14,7 +14,8 @@
#include "BAGuitar.h" #include "BAGuitar.h"
using namespace BAGuitar; using namespace BAEffects;
using namespace BALibrary;
AudioInputI2S i2sIn; AudioInputI2S i2sIn;
AudioOutputI2S i2sOut; AudioOutputI2S i2sOut;

@ -2,7 +2,8 @@
#include "BAGuitar.h" #include "BAGuitar.h"
using namespace midi; using namespace midi;
using namespace BAGuitar; using namespace BAEffects;
using namespace BALibrary;
AudioInputI2S i2sIn; AudioInputI2S i2sIn;
AudioOutputI2S i2sOut; AudioOutputI2S i2sOut;

@ -22,13 +22,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#ifndef __BAGUITAR_BAAUDIOEFFECTANALOGDELAY_H #ifndef __BAEFFECTS_BAAUDIOEFFECTANALOGDELAY_H
#define __BAGUITAR_BAAUDIOEFFECTANALOGDELAY_H #define __BAEFFECTS_BAAUDIOEFFECTANALOGDELAY_H
#include <Audio.h> #include <Audio.h>
#include "LibBasicFunctions.h" #include "LibBasicFunctions.h"
namespace BAGuitar { namespace BAEffects {
/**************************************************************************//** /**************************************************************************//**
* AudioEffectAnalogDelay models BBD based analog delays. It provides controls * AudioEffectAnalogDelay models BBD based analog delays. It provides controls
@ -72,7 +72,7 @@ public:
/// Construct an analog delay using external SPI via an ExtMemSlot. The amount of /// Construct an analog delay using external SPI via an ExtMemSlot. The amount of
/// delay will be determined by the amount of memory in the slot. /// delay will be determined by the amount of memory in the slot.
/// @param slot A pointer to the ExtMemSlot to use for the delay. /// @param slot A pointer to the ExtMemSlot to use for the delay.
AudioEffectAnalogDelay(ExtMemSlot *slot); // requires sufficiently sized pre-allocated memory AudioEffectAnalogDelay(BALibrary::ExtMemSlot *slot); // requires sufficiently sized pre-allocated memory
virtual ~AudioEffectAnalogDelay(); ///< Destructor virtual ~AudioEffectAnalogDelay(); ///< Destructor
@ -163,11 +163,11 @@ private:
bool m_bypass = true; bool m_bypass = true;
bool m_enable = false; bool m_enable = false;
bool m_externalMemory = false; bool m_externalMemory = false;
AudioDelay *m_memory = nullptr; BALibrary::AudioDelay *m_memory = nullptr;
size_t m_maxDelaySamples = 0; size_t m_maxDelaySamples = 0;
audio_block_t *m_previousBlock = nullptr; audio_block_t *m_previousBlock = nullptr;
audio_block_t *m_blockToRelease = nullptr; audio_block_t *m_blockToRelease = nullptr;
IirBiQuadFilterHQ *m_iir = nullptr; BALibrary::IirBiQuadFilterHQ *m_iir = nullptr;
// Controls // Controls
int m_midiConfig[NUM_CONTROLS][2]; // stores the midi parameter mapping int m_midiConfig[NUM_CONTROLS][2]; // stores the midi parameter mapping
@ -185,4 +185,4 @@ private:
} }
#endif /* __BAGUITAR_BAAUDIOEFFECTANALOGDELAY_H */ #endif /* __BAEFFECTS_BAAUDIOEFFECTANALOGDELAY_H */

@ -19,8 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#ifndef __BAGUITAR_BAAUDIOEFFECTSOS_H #ifndef __BAEFFECTS_BAAUDIOEFFECTSOS_H
#define __BAGUITAR_BAAUDIOEFFECTSOS_H #define __BAEFFECTS_BAAUDIOEFFECTSOS_H
#include <Audio.h> #include <Audio.h>
#include "LibBasicFunctions.h" #include "LibBasicFunctions.h"
@ -53,7 +53,7 @@ public:
/// Construct an analog delay using external SPI via an ExtMemSlot. The amount of /// Construct an analog delay using external SPI via an ExtMemSlot. The amount of
/// delay will be determined by the amount of memory in the slot. /// delay will be determined by the amount of memory in the slot.
/// @param slot A pointer to the ExtMemSlot to use for the delay. /// @param slot A pointer to the ExtMemSlot to use for the delay.
AudioEffectSOS(BAGuitar::ExtMemSlot *slot); // requires sufficiently sized pre-allocated memory AudioEffectSOS(BALibrary::ExtMemSlot *slot); // requires sufficiently sized pre-allocated memory
virtual ~AudioEffectSOS(); ///< Destructor virtual ~AudioEffectSOS(); ///< Destructor
@ -116,7 +116,7 @@ private:
bool m_isOmni = false; bool m_isOmni = false;
bool m_bypass = true; bool m_bypass = true;
bool m_enable = false; bool m_enable = false;
BAGuitar::AudioDelay *m_memory = nullptr; BALibrary::AudioDelay *m_memory = nullptr;
bool m_externalMemory = true; bool m_externalMemory = true;
audio_block_t *m_previousBlock = nullptr; audio_block_t *m_previousBlock = nullptr;
audio_block_t *m_blockToRelease = nullptr; audio_block_t *m_blockToRelease = nullptr;
@ -133,7 +133,7 @@ private:
// Automated Controls // Automated Controls
BALibrary::ParameterAutomationSequence<float> m_inputGateAuto = BALibrary::ParameterAutomationSequence<float> m_inputGateAuto =
BALibrary::ParameterAutomationSequence<float>(3); BALibrary::ParameterAutomationSequence<float>(3);
// Private functions // Private functions
void m_preProcessing (audio_block_t *out, audio_block_t *input, audio_block_t *delayedSignal); void m_preProcessing (audio_block_t *out, audio_block_t *input, audio_block_t *delayedSignal);
@ -142,4 +142,4 @@ private:
} }
#endif /* __BAGUITAR_BAAUDIOEFFECTANALOGDELAY_H */ #endif /* __BAEFFECTS_BAAUDIOEFFECTSOS_H */

@ -22,10 +22,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#ifndef __BAGUITAR__BAAUDIOCONTROLWM8731_H #ifndef __BALIBRARY_BAAUDIOCONTROLWM8731_H
#define __BAGUITAR__BAAUDIOCONTROLWM8731_H #define __BALIBRARY_BAAUDIOCONTROLWM8731_H
namespace BAGuitar { namespace BALibrary {
constexpr int WM8731_NUM_REGS = 10; // Number of registers in the internal shadow array constexpr int WM8731_NUM_REGS = 10; // Number of registers in the internal shadow array
@ -126,6 +126,6 @@ private:
}; };
} /* namespace BAGuitar */ } /* namespace BALibrary */
#endif /* __BAGUITAR__BAAUDIOCONTROLWM8731_H */ #endif /* __BALIBRARY_BAAUDIOCONTROLWM8731_H */

@ -22,15 +22,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#ifndef __BAGUITAR_BAAUDIOEFFECTDELAYEXTERNAL_H #ifndef __BAEFFECTS_BAAUDIOEFFECTDELAYEXTERNAL_H
#define __BAGUITAR_BAAUDIOEFFECTDELAYEXTERNAL_H #define __BAEFFECTS_BAAUDIOEFFECTDELAYEXTERNAL_H
#include <Audio.h> #include <Audio.h>
#include "AudioStream.h" #include "AudioStream.h"
#include "BAHardware.h" #include "BAHardware.h"
namespace BAGuitar { namespace BAEffects {
/**************************************************************************//** /**************************************************************************//**
* BAAudioEffectDelayExternal can use external SPI RAM for delay rather than * BAAudioEffectDelayExternal can use external SPI RAM for delay rather than
@ -45,12 +45,12 @@ public:
/// Specifiy which external memory to use /// Specifiy which external memory to use
/// @param type specify which memory to use /// @param type specify which memory to use
BAAudioEffectDelayExternal(BAGuitar::MemSelect type); BAAudioEffectDelayExternal(BALibrary::MemSelect type);
/// Specify external memory, and how much of the memory to use /// Specify external memory, and how much of the memory to use
/// @param type specify which memory to use /// @param type specify which memory to use
/// @param delayLengthMs maximum delay length in milliseconds /// @param delayLengthMs maximum delay length in milliseconds
BAAudioEffectDelayExternal(BAGuitar::MemSelect type, float delayLengthMs); BAAudioEffectDelayExternal(BALibrary::MemSelect type, float delayLengthMs);
virtual ~BAAudioEffectDelayExternal(); virtual ~BAAudioEffectDelayExternal();
/// set the actual amount of delay on a given delay tap /// set the actual amount of delay on a given delay tap
@ -67,7 +67,7 @@ public:
static unsigned m_usingSPICount[2]; // internal use for all instances static unsigned m_usingSPICount[2]; // internal use for all instances
private: private:
void initialize(BAGuitar::MemSelect mem, unsigned delayLength = 1e6); void initialize(BALibrary::MemSelect mem, unsigned delayLength = 1e6);
void read(uint32_t address, uint32_t count, int16_t *data); void read(uint32_t address, uint32_t count, int16_t *data);
void write(uint32_t address, uint32_t count, const int16_t *data); void write(uint32_t address, uint32_t count, const int16_t *data);
void zero(uint32_t address, uint32_t count); void zero(uint32_t address, uint32_t count);
@ -79,7 +79,7 @@ private:
static unsigned m_allocated[2]; static unsigned m_allocated[2];
audio_block_t *m_inputQueueArray[1]; audio_block_t *m_inputQueueArray[1];
BAGuitar::MemSelect m_mem; BALibrary::MemSelect m_mem;
SPIClass *m_spi = nullptr; SPIClass *m_spi = nullptr;
int m_spiChannel = 0; int m_spiChannel = 0;
int m_misoPin = 0; int m_misoPin = 0;
@ -92,6 +92,6 @@ private:
}; };
} /* namespace BAGuitar */ } /* namespace BAEffects */
#endif /* __BAGUITAR_BAAUDIOEFFECTDELAYEXTERNAL_H */ #endif /* __BAEFFECTS_BAAUDIOEFFECTDELAYEXTERNAL_H */

@ -20,12 +20,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#ifndef __BAGUITAR_BAGPIO_H #ifndef __BALIBRARY_BAGPIO_H
#define __BAGUITAR_BAGPIO_H #define __BALIBRARY_BAGPIO_H
#include "BAHardware.h" #include "BAHardware.h"
namespace BAGuitar { namespace BALibrary {
/**************************************************************************//** /**************************************************************************//**
* BAGpio provides a convince class to easily control the direction and state * BAGpio provides a convince class to easily control the direction and state
@ -71,6 +71,6 @@ private:
uint8_t m_ledState; uint8_t m_ledState;
}; };
} /* namespace BAGuitar */ } /* namespace BALibrary */
#endif /* __BAGUITAR_BAGPIO_H */ #endif /* __BALIBRARY_BAGPIO_H */

@ -20,15 +20,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#ifndef __BAGUTIAR_BAHARDWARE_H #ifndef __BALIBRARY_BAHARDWARE_H
#define __BAGUTIAR_BAHARDWARE_H #define __BALIBRARY_BAHARDWARE_H
#include <cstdint> #include <cstdint>
/**************************************************************************//** /**************************************************************************//**
* BAGuitar is a namespace/Library for Guitar processing from Blackaddr Audio. * BAGuitar is a namespace/Library for Guitar processing from Blackaddr Audio.
*****************************************************************************/ *****************************************************************************/
namespace BAGuitar { namespace BALibrary {
// uncomment the line that corresponds to your hardware // uncomment the line that corresponds to your hardware
#define TGA_PRO_REVA #define TGA_PRO_REVA
@ -93,7 +93,7 @@ constexpr size_t SPI_MEM1_MAX_AUDIO_SAMPLES = SPI_MEM1_SIZE_BYTES/sizeof(int16_t
#endif #endif
} // namespace BAGuitar } // namespace BALibrary
#endif /* __BAGUTIAR_BAHARDWARE_H */ #endif /* __BALIBRARY_BAHARDWARE_H */

@ -20,8 +20,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#ifndef __BAGUITAR_BASPIMEMORY_H #ifndef __BALIBRARY_BASPIMEMORY_H
#define __BAGUITAR_BASPIMEMORY_H #define __BALIBRARY_BASPIMEMORY_H
#include <SPI.h> #include <SPI.h>
#include <DmaSpi.h> #include <DmaSpi.h>
@ -29,7 +29,7 @@
#include "BATypes.h" #include "BATypes.h"
#include "BAHardware.h" #include "BAHardware.h"
namespace BAGuitar { namespace BALibrary {
/**************************************************************************//** /**************************************************************************//**
* This wrapper class uses the Arduino SPI (Wire) library to access the SPI ram. * This wrapper class uses the Arduino SPI (Wire) library to access the SPI ram.
@ -139,35 +139,41 @@ public:
/// initialize and configure the SPI peripheral /// initialize and configure the SPI peripheral
void begin() override; void begin() override;
/// Write a block of 8-bit data to the specified address /// Write a block of 8-bit data to the specified address. Be check
/// isWriteBusy() before sending the next DMA transfer.
/// @param address the address in the SPI RAM to write to /// @param address the address in the SPI RAM to write to
/// @param src pointer to the source data block /// @param src pointer to the source data block
/// @param numBytes size of the data block in bytes /// @param numBytes size of the data block in bytes
void write(size_t address, uint8_t *src, size_t numBytes) override; void write(size_t address, uint8_t *src, size_t numBytes) override;
/// Write a block of zeros to the specified address /// Write a block of zeros to the specified address. Be check
/// isWriteBusy() before sending the next DMA transfer.
/// @param address the address in the SPI RAM to write to /// @param address the address in the SPI RAM to write to
/// @param numBytes size of the data block in bytes /// @param numBytes size of the data block in bytes
void zero(size_t address, size_t numBytes) override; void zero(size_t address, size_t numBytes) override;
/// Write a block of 16-bit data to the specified address /// Write a block of 16-bit data to the specified address. Be check
/// isWriteBusy() before sending the next DMA transfer.
/// @param address the address in the SPI RAM to write to /// @param address the address in the SPI RAM to write to
/// @param src pointer to the source data block /// @param src pointer to the source data block
/// @param numWords size of the data block in 16-bit words /// @param numWords size of the data block in 16-bit words
void write16(size_t address, uint16_t *src, size_t numWords) override; void write16(size_t address, uint16_t *src, size_t numWords) override;
/// Write a block of 16-bit zeros to the specified address /// Write a block of 16-bit zeros to the specified address. Be check
/// isWriteBusy() before sending the next DMA transfer.
/// @param address the address in the SPI RAM to write to /// @param address the address in the SPI RAM to write to
/// @param numWords size of the data block in 16-bit words /// @param numWords size of the data block in 16-bit words
void zero16(size_t address, size_t numWords) override; void zero16(size_t address, size_t numWords) override;
/// Read a block of 8-bit data from the specified address /// Read a block of 8-bit data from the specified address. Be check
/// isReadBusy() before sending the next DMA transfer.
/// @param address the address in the SPI RAM to write to /// @param address the address in the SPI RAM to write to
/// @param dest pointer to the destination /// @param dest pointer to the destination
/// @param numBytes size of the data block in bytes /// @param numBytes size of the data block in bytes
void read(size_t address, uint8_t *dest, size_t numBytes) override; void read(size_t address, uint8_t *dest, size_t numBytes) override;
/// read a block 16-bit data word from the specified address /// read a block 16-bit data word from the specified address. Be check
/// isReadBusy() before sending the next DMA transfer.
/// @param address the address in the SPI RAM to read from /// @param address the address in the SPI RAM to read from
/// @param dest the pointer to the destination /// @param dest the pointer to the destination
/// @param numWords the number of 16-bit words to transfer /// @param numWords the number of 16-bit words to transfer
@ -210,6 +216,6 @@ private:
}; };
} /* namespace BAGuitar */ } /* namespace BALibrary */
#endif /* __BAGUITAR_BASPIMEMORY_H */ #endif /* __BALIBRARY_BASPIMEMORY_H */

@ -19,10 +19,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#ifndef __BAGUITAR_BATYPES_H #ifndef __BALIBRARY_BATYPES_H
#define __BAGUITAR_BATYPES_H #define __BALIBRARY_BATYPES_H
namespace BAGuitar { namespace BALibrary {
#define UNUSED(x) (void)(x) #define UNUSED(x) (void)(x)
@ -152,7 +152,7 @@ private:
const size_t m_maxSize; ///< maximum size of the queue const size_t m_maxSize; ///< maximum size of the queue
}; };
} // BAGuitar } // BALibrary
#endif /* __BAGUITAR_BATYPES_H */ #endif /* __BALIBRARY_BATYPES_H */

@ -30,10 +30,10 @@
#include "BATypes.h" #include "BATypes.h"
#include "LibMemoryManagement.h" #include "LibMemoryManagement.h"
#ifndef __BAGUITAR_LIBBASICFUNCTIONS_H #ifndef __BALIBRARY_LIBBASICFUNCTIONS_H
#define __BAGUITAR_LIBBASICFUNCTIONS_H #define __BALIBRARY_LIBBASICFUNCTIONS_H
namespace BAGuitar { namespace BALibrary {
/**************************************************************************//** /**************************************************************************//**
* QueuePosition is used for storing the index (in an array of queues) and the * QueuePosition is used for storing the index (in an array of queues) and the
@ -134,7 +134,7 @@ public:
/// @param maxDelayTimeMs max length of time you want in the buffer specified in milliseconds /// @param maxDelayTimeMs max length of time you want in the buffer specified in milliseconds
AudioDelay(float maxDelayTimeMs); AudioDelay(float maxDelayTimeMs);
/// Construct an audio buffer using a slot configured with the BAGuitar::ExternalSramManager /// Construct an audio buffer using a slot configured with the BALibrary::ExternalSramManager
/// @param slot a pointer to the slot representing the memory you wish to use for the buffer. /// @param slot a pointer to the slot representing the memory you wish to use for the buffer.
AudioDelay(ExtMemSlot *slot); AudioDelay(ExtMemSlot *slot);
@ -312,7 +312,7 @@ private:
}; };
} // namespace BAGuitar } // namespace BALibrary
namespace BALibrary { namespace BALibrary {
@ -399,4 +399,4 @@ private:
} // BALibrary } // BALibrary
#endif /* __BAGUITAR_LIBBASICFUNCTIONS_H */ #endif /* __BALIBRARY_LIBBASICFUNCTIONS_H */

@ -26,15 +26,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#ifndef __BAGUITAR_LIBMEMORYMANAGEMENT_H #ifndef __BALIBRARY_LIBMEMORYMANAGEMENT_H
#define __BAGUITAR_LIBMEMORYMANAGEMENT_H #define __BALIBRARY_LIBMEMORYMANAGEMENT_H
#include <cstddef> #include <cstddef>
#include "BAHardware.h" #include "BAHardware.h"
#include "BASpiMemory.h" #include "BASpiMemory.h"
namespace BAGuitar { namespace BALibrary {
/**************************************************************************//** /**************************************************************************//**
* MemConfig contains the configuration information associated with a particular * MemConfig contains the configuration information associated with a particular
@ -182,7 +182,7 @@ public:
/// @details note that currently, memory cannot be allocated. /// @details note that currently, memory cannot be allocated.
/// @param mem specifies which memory to query, default is memory 0 /// @param mem specifies which memory to query, default is memory 0
/// @returns the available memory in bytes /// @returns the available memory in bytes
size_t availableMemory(BAGuitar::MemSelect mem = BAGuitar::MemSelect::MEM0); size_t availableMemory(BALibrary::MemSelect mem = BALibrary::MemSelect::MEM0);
/// Request memory be allocated for the provided slot /// Request memory be allocated for the provided slot
/// @param slot a pointer to the global slot object to which memory will be allocated /// @param slot a pointer to the global slot object to which memory will be allocated
@ -190,7 +190,7 @@ public:
/// @param mem specify which external memory to allocate from /// @param mem specify which external memory to allocate from
/// @param useDma when true, DMA is used for SPI port, else transfers block until complete /// @param useDma when true, DMA is used for SPI port, else transfers block until complete
/// @returns true on success, otherwise false on error /// @returns true on success, otherwise false on error
bool requestMemory(ExtMemSlot *slot, float delayMilliseconds, BAGuitar::MemSelect mem = BAGuitar::MemSelect::MEM0, bool useDma = false); bool requestMemory(ExtMemSlot *slot, float delayMilliseconds, BALibrary::MemSelect mem = BALibrary::MemSelect::MEM0, bool useDma = false);
/// Request memory be allocated for the provided slot /// Request memory be allocated for the provided slot
/// @param slot a pointer to the global slot object to which memory will be allocated /// @param slot a pointer to the global slot object to which memory will be allocated
@ -198,15 +198,15 @@ public:
/// @param mem specify which external memory to allocate from /// @param mem specify which external memory to allocate from
/// @param useDma when true, DMA is used for SPI port, else transfers block until complete /// @param useDma when true, DMA is used for SPI port, else transfers block until complete
/// @returns true on success, otherwise false on error /// @returns true on success, otherwise false on error
bool requestMemory(ExtMemSlot *slot, size_t sizeBytes, BAGuitar::MemSelect mem = BAGuitar::MemSelect::MEM0, bool useDma = false); bool requestMemory(ExtMemSlot *slot, size_t sizeBytes, BALibrary::MemSelect mem = BALibrary::MemSelect::MEM0, bool useDma = false);
private: private:
static bool m_configured; ///< there should only be one instance of ExternalSramManager in the whole project static bool m_configured; ///< there should only be one instance of ExternalSramManager in the whole project
static MemConfig m_memConfig[BAGuitar::NUM_MEM_SLOTS]; ///< store the configuration information for each external memory static MemConfig m_memConfig[BALibrary::NUM_MEM_SLOTS]; ///< store the configuration information for each external memory
}; };
} } // BALibrary
#endif /* __LIBMEMORYMANAGEMENT_H */ #endif /* __BALIBRARY_LIBMEMORYMANAGEMENT_H */

@ -21,7 +21,7 @@
#include "Audio.h" #include "Audio.h"
#include "LibBasicFunctions.h" #include "LibBasicFunctions.h"
namespace BAGuitar { namespace BALibrary {
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
// AudioDelay // AudioDelay

@ -21,7 +21,7 @@
#include "Audio.h" #include "Audio.h"
#include "LibBasicFunctions.h" #include "LibBasicFunctions.h"
namespace BAGuitar { namespace BALibrary {
size_t calcAudioSamples(float milliseconds) size_t calcAudioSamples(float milliseconds)
{ {

@ -23,7 +23,7 @@
#include "Audio.h" #include "Audio.h"
#include "LibMemoryManagement.h" #include "LibMemoryManagement.h"
namespace BAGuitar { namespace BALibrary {
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// MEM SLOT // MEM SLOT

@ -23,13 +23,13 @@
#include "Audio.h" #include "Audio.h"
#include "LibMemoryManagement.h" #include "LibMemoryManagement.h"
namespace BAGuitar { namespace BALibrary {
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// EXTERNAL SRAM MANAGER // EXTERNAL SRAM MANAGER
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
bool ExternalSramManager::m_configured = false; bool ExternalSramManager::m_configured = false;
MemConfig ExternalSramManager::m_memConfig[BAGuitar::NUM_MEM_SLOTS]; MemConfig ExternalSramManager::m_memConfig[BALibrary::NUM_MEM_SLOTS];
ExternalSramManager::ExternalSramManager(unsigned numMemories) ExternalSramManager::ExternalSramManager(unsigned numMemories)
@ -60,19 +60,19 @@ ExternalSramManager::~ExternalSramManager()
} }
} }
size_t ExternalSramManager::availableMemory(BAGuitar::MemSelect mem) size_t ExternalSramManager::availableMemory(BALibrary::MemSelect mem)
{ {
return m_memConfig[mem].totalAvailable; return m_memConfig[mem].totalAvailable;
} }
bool ExternalSramManager::requestMemory(ExtMemSlot *slot, float delayMilliseconds, BAGuitar::MemSelect mem, bool useDma) bool ExternalSramManager::requestMemory(ExtMemSlot *slot, float delayMilliseconds, BALibrary::MemSelect mem, bool useDma)
{ {
// convert the time to numer of samples // convert the time to numer of samples
size_t delayLengthInt = (size_t)((delayMilliseconds*(AUDIO_SAMPLE_RATE_EXACT/1000.0f))+0.5f); size_t delayLengthInt = (size_t)((delayMilliseconds*(AUDIO_SAMPLE_RATE_EXACT/1000.0f))+0.5f);
return requestMemory(slot, delayLengthInt * sizeof(int16_t), mem, useDma); return requestMemory(slot, delayLengthInt * sizeof(int16_t), mem, useDma);
} }
bool ExternalSramManager::requestMemory(ExtMemSlot *slot, size_t sizeBytes, BAGuitar::MemSelect mem, bool useDma) bool ExternalSramManager::requestMemory(ExtMemSlot *slot, size_t sizeBytes, BALibrary::MemSelect mem, bool useDma)
{ {
if (m_memConfig[mem].totalAvailable >= sizeBytes) { if (m_memConfig[mem].totalAvailable >= sizeBytes) {
@ -86,10 +86,10 @@ bool ExternalSramManager::requestMemory(ExtMemSlot *slot, size_t sizeBytes, BAGu
if (!m_memConfig[mem].m_spi) { if (!m_memConfig[mem].m_spi) {
if (useDma) { if (useDma) {
m_memConfig[mem].m_spi = new BAGuitar::BASpiMemoryDMA(static_cast<BAGuitar::SpiDeviceId>(mem)); m_memConfig[mem].m_spi = new BALibrary::BASpiMemoryDMA(static_cast<BALibrary::SpiDeviceId>(mem));
slot->m_useDma = true; slot->m_useDma = true;
} else { } else {
m_memConfig[mem].m_spi = new BAGuitar::BASpiMemory(static_cast<BAGuitar::SpiDeviceId>(mem)); m_memConfig[mem].m_spi = new BALibrary::BASpiMemory(static_cast<BALibrary::SpiDeviceId>(mem));
slot->m_useDma = false; slot->m_useDma = false;
} }
if (!m_memConfig[mem].m_spi) { if (!m_memConfig[mem].m_spi) {

@ -21,7 +21,7 @@
#include "Audio.h" #include "Audio.h"
#include "LibBasicFunctions.h" #include "LibBasicFunctions.h"
namespace BAGuitar { namespace BALibrary {
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
// IirBiQuadFilter // IirBiQuadFilter

@ -20,8 +20,6 @@
#include "LibBasicFunctions.h" #include "LibBasicFunctions.h"
using namespace BAGuitar;
namespace BALibrary { namespace BALibrary {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

@ -8,7 +8,9 @@
#include "AudioEffectAnalogDelayFilters.h" #include "AudioEffectAnalogDelayFilters.h"
#include "AudioEffectAnalogDelay.h" #include "AudioEffectAnalogDelay.h"
namespace BAGuitar { using namespace BALibrary;
namespace BAEffects {
constexpr int MIDI_CHANNEL = 0; constexpr int MIDI_CHANNEL = 0;
constexpr int MIDI_CONTROL = 1; constexpr int MIDI_CONTROL = 1;

@ -21,7 +21,7 @@
*****************************************************************************/ *****************************************************************************/
#include <cstdint> #include <cstdint>
namespace BAGuitar { namespace BAEffects {
// The number of stages in the analog-response Biquad filter // The number of stages in the analog-response Biquad filter
constexpr unsigned MAX_NUM_FILTER_STAGES = 4; constexpr unsigned MAX_NUM_FILTER_STAGES = 4;

@ -8,7 +8,6 @@
#include "AudioEffectSOS.h" #include "AudioEffectSOS.h"
#include "LibBasicFunctions.h" #include "LibBasicFunctions.h"
using namespace BAGuitar;
using namespace BALibrary; using namespace BALibrary;
namespace BAEffects { namespace BAEffects {

@ -20,7 +20,9 @@
#include "BAAudioEffectDelayExternal.h" #include "BAAudioEffectDelayExternal.h"
namespace BAGuitar { using namespace BALibrary;
namespace BAEffects {
#define SPISETTING SPISettings(20000000, MSBFIRST, SPI_MODE0) #define SPISETTING SPISettings(20000000, MSBFIRST, SPI_MODE0)
@ -49,7 +51,7 @@ BAAudioEffectDelayExternal::BAAudioEffectDelayExternal(MemSelect mem)
initialize(mem); initialize(mem);
} }
BAAudioEffectDelayExternal::BAAudioEffectDelayExternal(BAGuitar::MemSelect type, float delayLengthMs) BAAudioEffectDelayExternal::BAAudioEffectDelayExternal(BALibrary::MemSelect type, float delayLengthMs)
: AudioStream(1, m_inputQueueArray) : AudioStream(1, m_inputQueueArray)
{ {
unsigned delayLengthInt = (delayLengthMs*(AUDIO_SAMPLE_RATE_EXACT/1000.0f))+0.5f; unsigned delayLengthInt = (delayLengthMs*(AUDIO_SAMPLE_RATE_EXACT/1000.0f))+0.5f;
@ -289,4 +291,4 @@ inline void BAAudioEffectDelayExternal::m_stopUsingSPI(int spiBus) {
#endif #endif
} /* namespace BAGuitar */ } /* namespace BAEffects */

@ -21,7 +21,7 @@
#include <Wire.h> #include <Wire.h>
#include "BAAudioControlWM8731.h" #include "BAAudioControlWM8731.h"
namespace BAGuitar { namespace BALibrary {
// use const instead of define for proper scoping // use const instead of define for proper scoping
constexpr int WM8731_I2C_ADDR = 0x1A; constexpr int WM8731_I2C_ADDR = 0x1A;
@ -341,4 +341,4 @@ bool BAAudioControlWM8731::write(unsigned int reg, unsigned int val)
return true; return true;
} }
} /* namespace BAGuitar */ } /* namespace BALibrary */

@ -21,7 +21,7 @@
#include "Arduino.h" #include "Arduino.h"
#include "BAGpio.h" #include "BAGpio.h"
namespace BAGuitar { namespace BALibrary {
BAGpio::BAGpio() BAGpio::BAGpio()
{ {
@ -85,4 +85,4 @@ int BAGpio::toggleLed()
} }
} /* namespace BAGuitar */ } /* namespace BALibrary */

@ -21,7 +21,7 @@
#include "Arduino.h" #include "Arduino.h"
#include "BASpiMemory.h" #include "BASpiMemory.h"
namespace BAGuitar { namespace BALibrary {
// MEM0 Settings // MEM0 Settings
constexpr int SPI_CS_MEM0 = 15; constexpr int SPI_CS_MEM0 = 15;
@ -468,4 +468,4 @@ bool BASpiMemoryDMA::isReadBusy(void) const
return (m_rxTransfer[0].busy() or m_rxTransfer[1].busy()); return (m_rxTransfer[0].busy() or m_rxTransfer[1].busy());
} }
} /* namespace BAGuitar */ } /* namespace BALibrary */

Loading…
Cancel
Save