Created
August 9, 2018 14:29
-
-
Save jpcima/044c1040236fed413d5adf91deaa90fe to your computer and use it in GitHub Desktop.
RtAudio #123
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "RtAudio.h" | |
#include <string.h> | |
#include <unistd.h> | |
static int channels = 0; | |
int audio_callback( | |
void *outputBuffer, void *inputBuffer, | |
unsigned int nFrames, | |
double streamTime, | |
RtAudioStreamStatus status, | |
void *userData) | |
{ | |
memset(outputBuffer, 0, channels * nFrames * sizeof(float)); | |
return 0; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
int channels = 0; | |
if (argc != 2 || (channels = atoi(argv[1])) < 1) { | |
fprintf(stderr, "You must pass a channel count argument!\n"); | |
return 1; | |
} | |
::channels = channels; | |
RtAudio *audio = new RtAudio(RtAudio::UNIX_JACK); | |
RtAudio::StreamParameters inp; | |
inp.nChannels = channels; | |
inp.deviceId = audio->getDefaultInputDevice(); | |
RtAudio::StreamParameters outp; | |
outp.nChannels = channels; | |
outp.deviceId = audio->getDefaultOutputDevice(); | |
RtAudio::StreamOptions opts; | |
opts.flags = RTAUDIO_JACK_DONT_CONNECT; | |
opts.streamName = "RtAudio with JACK"; | |
unsigned rate = audio->getDeviceInfo(inp.deviceId).preferredSampleRate; | |
unsigned bs = 1024; | |
fprintf(stderr, "Open Stream\n"); | |
audio->openStream(&outp, &inp, RTAUDIO_FLOAT32, rate, &bs, &audio_callback, nullptr, &opts); | |
fprintf(stderr, "Start Stream\n"); | |
audio->startStream(); | |
for (;;) | |
pause(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment