switch from qtMedia to rtAudio
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
|
||||
#include "AudioStream.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
AudioStream::AudioStream(Synth *synth, QObject *parent) : QIODevice(parent), synth_(synth) {
|
||||
|
||||
}
|
||||
|
||||
void AudioStream::start() {
|
||||
|
||||
// std::cout << "AudioStream::start()" << std::endl;
|
||||
open(QIODevice::ReadOnly);
|
||||
}
|
||||
|
||||
void AudioStream::stop() {
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
qint64 AudioStream::readData(char *data, qint64 maxlen) {
|
||||
|
||||
// std::cout << "sample out " << std::endl;
|
||||
QByteArray samples = synth_->generateSamples(maxlen);
|
||||
memcpy(data, samples.constData(), samples.size());
|
||||
return samples.size();
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QIODevice>
|
||||
#include "Synth.h"
|
||||
|
||||
class AudioStream : public QIODevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AudioStream(Synth *synth, QObject *parent = nullptr);
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
protected:
|
||||
qint64 readData(char *data, qint64 maxlen) override;
|
||||
qint64 writeData(const char *, qint64) override { return 0; }
|
||||
|
||||
private:
|
||||
Synth *synth_;
|
||||
};
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
/*
|
||||
|
||||
#include "Synth.h"
|
||||
|
||||
#include <QMediaDevices>
|
||||
@@ -28,13 +30,12 @@ Synth::~Synth() {
|
||||
|
||||
void Synth::start() {
|
||||
|
||||
/*
|
||||
// std::cout << "Synth::start()" << std::endl;
|
||||
if (audioSink_->state() == QAudio::ActiveState)
|
||||
return;
|
||||
// if (audioSink_->state() == QAudio::ActiveState)
|
||||
// return;
|
||||
|
||||
audioDevice_ = audioSink_->start();
|
||||
*/
|
||||
// audioDevice_ = audioSink_->start();
|
||||
|
||||
}
|
||||
|
||||
void Synth::stop() {
|
||||
@@ -109,4 +110,6 @@ void Synth::applyConfig(const AudioConfig& config) {
|
||||
audioSink_ = new QAudioSink(device, format_, this);
|
||||
|
||||
audioSink_->setBufferSize(config.bufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
|
||||
#include <QObject>
|
||||
#include <QAudioFormat>
|
||||
#include <QAudioSink>
|
||||
@@ -45,4 +47,6 @@ private:
|
||||
float phase_ = 0.0f;
|
||||
|
||||
float freq = 400.0f;
|
||||
};
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user