https://github.com/ales-tsurko/ataudioprocessinglibrary
A ready-to-use collection of unit generators and utility functions for DSP programming
https://github.com/ales-tsurko/ataudioprocessinglibrary
audio dsp
Last synced: 2 months ago
JSON representation
A ready-to-use collection of unit generators and utility functions for DSP programming
- Host: GitHub
- URL: https://github.com/ales-tsurko/ataudioprocessinglibrary
- Owner: ales-tsurko
- License: mit
- Created: 2017-04-16T03:28:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-15T08:25:46.000Z (over 6 years ago)
- Last Synced: 2025-01-28T18:30:00.534Z (8 months ago)
- Topics: audio, dsp
- Language: Objective-C++
- Homepage:
- Size: 38.1 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE.md
Awesome Lists containing this project
README
A ready-to-use collection of high performance unit generators and utility functions for DSP programming.
Depends on Apple's Accelerate framework, so apple platforms only.
## Content
### Ugens
#### Delay
SingleDelay#### Distortion
SaturatedAmp#### Effects
ChorusSpringReverb
#### Filters
AllpassFilterFIRLP
SVF
OnePoleLPHP
TwoPoleSVFS
BiquadSVF
#### Generators
ParabolicWMTriLFOStereo
LFO
### Utility
midiToFreq(noteNumber)
frequencyToMIDI(freq)
clamp(input, low, high)
threePointShaper(in, start, mid, end)
twoPointShaper(in, outStart, outEnd)linearToLog(input, minIn, maxIn, minOut, maxOut)
dBToAmp(input)## Usage
Link `Accelerate.framework`, then include `ATAudioProcessing.hpp`.Use the `.calculateBlock` method, then copy the `.output` into buffer.
The example of a process function will look like this:
```cpp
// The code looks complex, but it's calculated per vectorized block,
// so it quite outperforms the sample-by-sample approach.// ParabolicWM oscillator;
// oscillator.init(sampleRate, channelCount, calculationBlockSize, oversamplingFactor);void process(AUAudioFrameCount frameCount, AUAudioFrameCount bufferOffset) override {
AudioBuffer *out = outBufferListPtr->mBuffers;
for (int frameOffset = 0; frameOffset < frameCount; frameOffset+=calculationBlockSize) {
//
// Fill the rest of the output from the previous iteration
// (to prevent problems, which may occur with variable framerate)
//
if (frameCount - frameOffset < preGenWriteIndex) {
preGenWriteIndex = frameCount - frameOffset;
}
if (preGenWriteIndex != 0) {
for (int channel = 0; channel < numberOfChannels; ++channel) {
sample_t *outChannel = (sample_t *)out[channel].mData;
memcpy(outChannel+frameOffset, &oscillator.output[channel][postGenWriteIndex],
preGenWriteIndex*sizeof(sample_t));
}
}
if (preGenWriteIndex + frameOffset == frameCount) {
postGenWriteIndex += preGenWriteIndex;
break;
}//
// block calculation
// put here your DSP part
//
oscillator.calculateBlock(440, 0.5, 1);
//
// copying to the output
//
if (frameCount - frameOffset < calculationBlockSize) {
postGenWriteIndex = frameCount - frameOffset - preGenWriteIndex;
}for (int channel = 0; channel < numberOfChannels; ++channel) {
sample_t *outChannel = (sample_t *)out[channel].mData;
memcpy(outChannel+frameOffset+preGenWriteIndex, &oscillator.output[channel][0],
postGenWriteIndex*sizeof(sample_t));
}
}
preGenWriteIndex = calculationBlockSize - postGenWriteIndex;
}```