mirror of
https://github.com/damp11113/EasyMPX.git
synced 2025-04-27 22:48:09 +00:00
Perfect Stereo update
This commit is contained in:
parent
a623d567d0
commit
91bc012286
@ -76,7 +76,7 @@ int main() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const int framesPerBuffer = 4096;
|
||||
const int framesPerBuffer = 19200;
|
||||
float* buffer = new float[framesPerBuffer * inputParameters.channelCount];
|
||||
std::vector<Band> bands = {
|
||||
{137, -20.2, 1, 3, 1, 100}, // Example parameters for Band 1
|
||||
@ -86,8 +86,9 @@ int main() {
|
||||
};
|
||||
float* piloToneBuffer = new float[framesPerBuffer];
|
||||
float* stereoToneBuffer = new float[framesPerBuffer];
|
||||
generateSineWave(piloToneBuffer, framesPerBuffer, 192000, 19000, 0.08f);
|
||||
generateSineWave(stereoToneBuffer, framesPerBuffer, 192000, 38000, 1);
|
||||
SignalGenerator::GenerateSineWave(piloToneBuffer, framesPerBuffer, 19000, 0.08f);
|
||||
SignalGenerator::GenerateSineWave(stereoToneBuffer, framesPerBuffer, 38000, 1);
|
||||
|
||||
|
||||
|
||||
while (true) {
|
||||
|
@ -1,16 +1,18 @@
|
||||
#include "PaMPXFunc.h"
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
void generateSineWave(float* buffer, int frames, int sampleRate, float frequency, float amplitude = 0.5f) {
|
||||
const float twoPi = 2.0f * 3.14159f;
|
||||
float phaseIncrement = (frequency / sampleRate) * twoPi;
|
||||
float phase = 0.0f;
|
||||
void SignalGenerator::GenerateSineWave(float* buffer, unsigned long frames, float frequency, float amplitude, int samplerate) {
|
||||
const double phaseIncrement = frequency / samplerate;
|
||||
const double cycles = frames / samplerate; // Number of cycles in the buffer
|
||||
double phase = 0.0;
|
||||
|
||||
for (unsigned long i = 0; i < frames; ++i) {
|
||||
buffer[i] = amplitude * sin(2.0 * M_PI * phase);
|
||||
|
||||
for (int i = 0; i < frames; ++i) {
|
||||
buffer[i] = amplitude * sin(phase);
|
||||
phase += phaseIncrement;
|
||||
if (phase > twoPi) {
|
||||
phase -= twoPi;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,15 @@
|
||||
#ifndef PAMPXFUNC_H
|
||||
#define PAMPXFUNC_H
|
||||
|
||||
#define M_PI 3.14159265358979323846
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
class SignalGenerator {
|
||||
public:
|
||||
static void GenerateSineWave(float* buffer, unsigned long frames, float frequency, float amplitude, int samplerate=192000);
|
||||
};
|
||||
|
||||
|
||||
void generateSineWave(float* buffer, int frames, int sampleRate, float frequency, float amplitude = 0.5f);
|
||||
|
||||
void mix(float* mixedBuffer, const float* buffers[], int numBuffers, int frames);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user