summaryrefslogtreecommitdiff
path: root/drumgizmo/output
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-12-05 20:34:12 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2014-12-05 20:34:12 +0100
commit3b0d9e0c9c5e08b2e449aa266617fb1db86b5a22 (patch)
treef203a59c944714925d73ae2d33ad9c67d5b17070 /drumgizmo/output
parent29ec8552826f64bfa8cad01a433306886328c522 (diff)
parent2e7176bc558cb03d4e7c27769bab9cd45c703332 (diff)
Merge branch 'resample'
Add resample support.
Diffstat (limited to 'drumgizmo/output')
-rw-r--r--drumgizmo/output/alsa/alsa.cc29
-rw-r--r--drumgizmo/output/dummy/dummy.cc30
-rw-r--r--drumgizmo/output/jackaudio/jackaudio.cc29
-rw-r--r--drumgizmo/output/wavfile/wavfile.cc38
4 files changed, 54 insertions, 72 deletions
diff --git a/drumgizmo/output/alsa/alsa.cc b/drumgizmo/output/alsa/alsa.cc
index 7b3a395..dc2ac73 100644
--- a/drumgizmo/output/alsa/alsa.cc
+++ b/drumgizmo/output/alsa/alsa.cc
@@ -49,6 +49,7 @@ public:
void pre(size_t size);
void run(int channel, sample_t* data, size_t size);
void post(size_t size);
+ size_t samplerate();
private:
snd_pcm_t *handle;
@@ -157,6 +158,11 @@ void Alsa::post(size_t size)
snd_pcm_writei(handle, data, size);
}
+size_t Alsa::samplerate()
+{
+ return srate;
+}
+
extern "C" {
void *create()
{
@@ -210,21 +216,10 @@ extern "C" {
Alsa *alsa = (Alsa*)h;
alsa->post(s);
}
-}
-
-#ifdef TEST_AUDIOOUTPUTENGINEALSA
-//Additional dependency files
-//deps:
-//Required cflags (autoconf vars may be used)
-//cflags:
-//Required link options (autoconf vars may be used)
-//libs:
-#include "test.h"
-
-TEST_BEGIN;
-// TODO: Put some testcode here (see test.h for usable macros).
-
-TEST_END;
-
-#endif/*TEST_AUDIOOUTPUTENGINEALSA*/
+ size_t samplerate(void *h)
+ {
+ Alsa *alsa = (Alsa*)h;
+ return alsa->samplerate();
+ }
+}
diff --git a/drumgizmo/output/dummy/dummy.cc b/drumgizmo/output/dummy/dummy.cc
index cd210dc..e60f2b7 100644
--- a/drumgizmo/output/dummy/dummy.cc
+++ b/drumgizmo/output/dummy/dummy.cc
@@ -43,6 +43,8 @@ public:
void pre(size_t size);
void run(int channel, sample_t* data, size_t size);
void post(size_t size);
+
+ size_t samplerate();
};
Dummy::Dummy()
@@ -83,6 +85,11 @@ void Dummy::post(size_t size)
{
}
+size_t Dummy::samplerate()
+{
+ return 44100;
+}
+
extern "C" {
void *create()
{
@@ -136,21 +143,10 @@ extern "C" {
Dummy *dummy = (Dummy*)h;
dummy->post(size);
}
-}
-
-#ifdef TEST_AUDIOOUTPUTENGINEDUMMY
-//Additional dependency files
-//deps:
-//Required cflags (autoconf vars may be used)
-//cflags:
-//Required link options (autoconf vars may be used)
-//libs:
-#include "test.h"
-
-TEST_BEGIN;
-// TODO: Put some testcode here (see test.h for usable macros).
-
-TEST_END;
-
-#endif/*TEST_AUDIOOUTPUTENGINEDUMMY*/
+ size_t samplerate(void *h)
+ {
+ Dummy *dummy = (Dummy*)h;
+ return dummy->samplerate();
+ }
+}
diff --git a/drumgizmo/output/jackaudio/jackaudio.cc b/drumgizmo/output/jackaudio/jackaudio.cc
index 2afe1ea..5c04146 100644
--- a/drumgizmo/output/jackaudio/jackaudio.cc
+++ b/drumgizmo/output/jackaudio/jackaudio.cc
@@ -54,6 +54,7 @@ public:
void jack_process(jack_nframes_t nframes);
size_t bufsize();
+ size_t samplerate();
private:
JackClient *jackclient;
@@ -146,6 +147,11 @@ size_t JackAudio::bufsize()
return jack_get_buffer_size(jackclient->jack_client);
}
+size_t JackAudio::samplerate()
+{
+ return jack_get_sample_rate(jackclient->jack_client);
+}
+
extern "C" {
void *create()
{
@@ -205,21 +211,10 @@ extern "C" {
JackAudio *jack = (JackAudio*)h;
return jack->bufsize();
}
-}
-
-#ifdef TEST_AUDIOINPUTENGINEJACKAUDIO
-//Additional dependency files
-//deps:
-//Required cflags (autoconf vars may be used)
-//cflags:
-//Required link options (autoconf vars may be used)
-//libs:
-#include "test.h"
-
-TEST_BEGIN;
-// TODO: Put some testcode here (see test.h for usable macros).
-
-TEST_END;
-
-#endif/*TEST_AUDIOINPUTENGINEJACKAUDIO*/
+ size_t samplerate(void *h)
+ {
+ JackAudio *jack = (JackAudio*)h;
+ return jack->samplerate();
+ }
+}
diff --git a/drumgizmo/output/wavfile/wavfile.cc b/drumgizmo/output/wavfile/wavfile.cc
index cb95715..fa4128e 100644
--- a/drumgizmo/output/wavfile/wavfile.cc
+++ b/drumgizmo/output/wavfile/wavfile.cc
@@ -44,6 +44,7 @@ public:
void pre(size_t size);
void run(int channel, sample_t* data, size_t size);
void post(size_t size);
+ size_t samplerate();
private:
SF_INFO sf_info;
@@ -58,6 +59,10 @@ WavFile::WavFile()
{
fh = NULL;
filename = "output";
+
+ sf_info.channels = 1;//channels;
+ sf_info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
+ sf_info.samplerate = 44100;
}
WavFile::~WavFile()
@@ -74,10 +79,6 @@ WavFile::~WavFile()
bool WavFile::init(int channels, char *cnames[])
{
this->channels = channels;
-
- sf_info.channels = 1;//channels;
- sf_info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
- sf_info.samplerate = 44100;
fh = (SNDFILE **)malloc(sizeof(SNDFILE *)*channels);
@@ -102,6 +103,7 @@ bool WavFile::init(int channels, char *cnames[])
void WavFile::setParm(std::string parm, std::string value)
{
if(parm == "file") filename = value;
+ if(parm == "srate") sf_info.samplerate = atoi(value.c_str());
}
bool WavFile::start()
@@ -126,6 +128,11 @@ void WavFile::post(size_t size)
{
}
+size_t WavFile::samplerate()
+{
+ return sf_info.samplerate;
+}
+
extern "C" {
void *create()
{
@@ -179,21 +186,10 @@ extern "C" {
WavFile *sndfile = (WavFile*)h;
sndfile->post(s);
}
-}
-
-#ifdef TEST_AUDIOOUTPUTENGINESNDFILE
-//Additional dependency files
-//deps:
-//Required cflags (autoconf vars may be used)
-//cflags:
-//Required link options (autoconf vars may be used)
-//libs:
-#include "test.h"
-
-TEST_BEGIN;
-
-// TODO: Put some testcode here (see test.h for usable macros).
-TEST_END;
-
-#endif/*TEST_AUDIOOUTPUTENGINESNDFILE*/
+ size_t samplerate(void *h)
+ {
+ WavFile *wavfile = (WavFile*)h;
+ return wavfile->samplerate();
+ }
+}