Skip to content

Instantly share code, notes, and snippets.

Created December 24, 2010 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/754387 to your computer and use it in GitHub Desktop.
Save anonymous/754387 to your computer and use it in GitHub Desktop.
1) Directory Skeleton
[sun@example voice]$ tree
.
├── build
│ └── Debug
│ └── GNU-Linux-x86
│ ├── main.o
│ └── main.o.d
├── dist
│ └── Debug
│ └── GNU-Linux-x86
├── include
│ └── mod_speex.h
├── lib
│ └── rtaudio
│ ├── config.log
│ ├── config.status
│ ├── configure
│ ├── configure.ac
│ ├── include
│ │ ├── asio.cpp
│ │ ├── asiodrivers.cpp
│ │ ├── asiodrivers.h
│ │ ├── asiodrvr.h
│ │ ├── asio.h
│ │ ├── asiolist.cpp
│ │ ├── asiolist.h
│ │ ├── asiosys.h
│ │ ├── dsound.h
│ │ ├── ginclude.h
│ │ ├── iasiodrv.h
│ │ ├── iasiothiscallresolver.cpp
│ │ ├── iasiothiscallresolver.h
│ │ └── soundcard.h
│ ├── install
│ ├── librtaudio.a
│ ├── librtaudio.so
│ ├── Makefile
│ ├── Makefile.in
│ ├── playback
│ ├── playback.cpp
│ ├── readme
│ ├── rtaudio-4.0.7-Makefile.mk
│ ├── rtaudio-config
│ ├── rtaudio-config.in
│ ├── RtAudio.cpp
│ ├── RtAudio.h
│ ├── RtAudio.o
│ ├── RtError.h
│ └── tests
│ ├── audioprobe.cpp
│ ├── Debug
│ ├── duplex.cpp
│ ├── Makefile
│ ├── Makefile.in
│ ├── playraw.cpp
│ ├── playsaw.cpp
│ ├── record.cpp
│ ├── Release
│ ├── test1.cpp
│ ├── testall.cpp
│ └── Windows
│ ├── audioprobe.dsp
│ ├── Debug
│ ├── duplex.dsp
│ ├── playraw.dsp
│ ├── playsaw.dsp
│ ├── record.dsp
│ ├── Release
│ ├── rtaudio.dsw
│ └── testall.dsp
├── main.cpp
├── Makefile
├── nbproject
│ ├── configurations.xml
│ ├── Makefile-Debug.mk
│ ├── Makefile-impl.mk
│ ├── Makefile-Release.mk
│ ├── Makefile-variables.mk
│ ├── Package-Debug.bash
│ ├── Package-Release.bash
│ ├── private
│ │ ├── configurations.xml
│ │ └── private.properties
│ ├── project.properties
│ └── project.xml
└── src
└── mod_speex.cpp
19 directories, 66 files
[sun@example voice]$
2) Skeleton is fine, but RtAudio, compile fail
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .clean-conf
gmake[1]: Entering directory `/home/sun/voice/voice'
rm -f -r build/Debug
rm -f dist/Debug/GNU-Linux-x86/voice
gmake[1]: Leaving directory `/home/sun/voice/voice'
CLEAN SUCCESSFUL (total time: 217ms)
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory `/home/sun/voice/voice'
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/voice
gmake[2]: Entering directory `/home/sun/voice/voice'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -O2 -Wall -DHAVE_GETTIMEOFDAY -D__LINUX_ALSA__ -c -g -I../../Downloads/fltk-1.1.10 -I../../Downloads/fltk-1.1.10/jpeg -I../../Downloads/fltk-1.1.10/zlib -I../../Downloads/fltk-1.1.10/png -Ilib/rtaudio -Ilib/rtaudio/include -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++ -O2 -Wall -DHAVE_GETTIMEOFDAY -D__LINUX_ALSA__ -lpthread -lasound -o dist/Debug/GNU-Linux-x86/voice build/Debug/GNU-Linux-x86/main.o -lfltk
build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/sun/voice/voice/main.cpp:44: undefined reference to `RtAudio::RtAudio(RtAudio::Api)'
/home/sun/voice/voice/main.cpp:59: undefined reference to `RtAudio::openStream(RtAudio::StreamParameters*, RtAudio::StreamParameters*, unsigned long, unsigned int, unsigned int*, int (*)(void*, void*, unsigned int, double, unsigned int, void*), void*, RtAudio::StreamOptions*)'
gmake[2]: Leaving directory `/home/sun/voice/voice'
/home/sun/voice/voice/main.cpp:83: undefined reference to `RtAudio::~RtAudio()'
gmake[1]: Leaving directory `/home/sun/voice/voice'
/home/sun/voice/voice/main.cpp:83: undefined reference to `RtAudio::~RtAudio()'
collect2: ld returned 1 exit status
gmake[2]: *** [dist/Debug/GNU-Linux-x86/voice] Error 1
gmake[1]: *** [.build-conf] Error 2
gmake: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
3) Bootstrap -> main.cpp got the following code:
/* Default usage */
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <cstring>
/* GUI */
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
/* Audio */
#include "RtAudio.h"
using namespace std;
int record( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *userData )
{
if ( status )
std::cout << "Stream overflow detected!" << std::endl;
return 0;
}
/* Boot */
int main(int argc, char **argv)
{
/* A) Welcome */
Fl_Window *window = new Fl_Window(300,180);
Fl_Box *box = new Fl_Box(20,40,260,100,"Hello, World!");
box->box(FL_UP_BOX);
box->labelsize(36);
box->labelfont(FL_BOLD+FL_ITALIC);
box->labeltype(FL_SHADOW_LABEL);
window->end();
window->show(argc, argv);
/* B) Rocket launch prepare */
RtAudio adc;
if ( adc.getDeviceCount() < 1 ) {
std::cout << "\nNo audio devices found!\n";
exit( 0 );
}
RtAudio::StreamParameters parameters;
parameters.deviceId = adc.getDefaultInputDevice();
parameters.nChannels = 2;
parameters.firstChannel = 0;
unsigned int sampleRate = 44100;
unsigned int bufferFrames = 256; // 256 sample frames
try {
adc.openStream( NULL, &parameters, RTAUDIO_SINT16,
sampleRate, &bufferFrames, &record );
adc.startStream();
}
catch ( RtError& e ) {
e.printMessage();
exit( 0 );
}
char input;
std::cout << "\nRecording ... press <enter> to quit.\n";
std::cin.get( input );
try {
// Stop the stream
adc.stopStream();
}
catch (RtError& e) {
e.printMessage();
}
if ( adc.isStreamOpen() ) adc.closeStream();
//return 0;
return Fl::run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment