mirror of
https://github.com/thestk/stk
synced 2026-01-15 05:51:52 +00:00
Version 4.1
This commit is contained in:
committed by
Stephen Sinclair
parent
81475b04c5
commit
2f09fcd019
0
projects/examples/Debug/.placeholder
Normal file
0
projects/examples/Debug/.placeholder
Normal file
@@ -1,58 +0,0 @@
|
||||
# Examples Makefile - Global version for Unix systems which have GNU
|
||||
# Makefile utilities installed.
|
||||
|
||||
OS = $(shell uname)
|
||||
|
||||
# You might have to modify the following path if you move things
|
||||
# around on your system.
|
||||
STK_SRC = ../../src/
|
||||
INCLUDE = -I../../include
|
||||
RM = /bin/rm
|
||||
|
||||
INSTR = sine play record io tcpIn tcpOut Moogy
|
||||
|
||||
ifeq ($(OS),Linux) # These are for Linux
|
||||
CC = g++ -O3 -Wall -D__LITTLE_ENDIAN__ -D__LINUX_OSS__
|
||||
LIBRARY = -lpthread -lm #-lasound
|
||||
endif
|
||||
|
||||
ifeq ($(OS),IRIX) # These are for SGI
|
||||
CC = CC -D__IRIX_AL__ # -g -fullwarn -O2
|
||||
LIBRARY = -L/usr/sgitcl/lib -laudio -lmd -lm -lpthread
|
||||
endif
|
||||
|
||||
%.o : $(STK_SRC)%.cpp
|
||||
$(CC) $(INCLUDE) -c $(<) -o $@
|
||||
|
||||
all: $(INSTR)
|
||||
|
||||
clean :
|
||||
rm *.o
|
||||
rm $(INSTR)
|
||||
|
||||
cleanIns :
|
||||
rm $(INSTR)
|
||||
|
||||
strip :
|
||||
strip $(INSTR)
|
||||
|
||||
play: play.cpp Stk.o WvIn.o WvOut.o RtWvOut.o RtAudio.o
|
||||
$(CC) -o play play.cpp Stk.o WvIn.o WvOut.o RtWvOut.o RtAudio.o $(LIBRARY) $(INCLUDE)
|
||||
|
||||
record: record.cpp Stk.o WvIn.o WvOut.o RtWvIn.o RtAudio.o
|
||||
$(CC) -o record record.cpp Stk.o WvIn.o WvOut.o RtWvIn.o RtAudio.o $(LIBRARY) $(INCLUDE)
|
||||
|
||||
sine: sine.cpp Stk.o WvIn.o WvOut.o WaveLoop.o
|
||||
$(CC) -o sine sine.cpp Stk.o WvIn.o WvOut.o WaveLoop.o $(LIBRARY) $(INCLUDE)
|
||||
|
||||
io: io.cpp Stk.o RtAudio.o RtDuplex.o
|
||||
$(CC) -o io io.cpp Stk.o RtAudio.o RtDuplex.o $(LIBRARY) $(INCLUDE)
|
||||
|
||||
tcpIn: tcpIn.cpp Stk.o WvIn.o TcpWvIn.o WvOut.o RtWvOut.o RtAudio.o Socket.o Thread.o
|
||||
$(CC) -o tcpIn tcpIn.cpp Stk.o WvIn.o Socket.o Thread.o TcpWvIn.o WvOut.o RtWvOut.o RtAudio.o $(LIBRARY) $(INCLUDE)
|
||||
|
||||
tcpOut: tcpOut.cpp Stk.o WvIn.o WvOut.o TcpWvOut.o Socket.o Thread.o
|
||||
$(CC) -o tcpOut tcpOut.cpp Stk.o WvIn.o WvOut.o Socket.o Thread.o TcpWvOut.o $(LIBRARY) $(INCLUDE)
|
||||
|
||||
Moogy: Moogy.cpp Stk.o WvIn.o WaveLoop.o WvOut.o RtWvOut.o RtAudio.o Instrmnt.o Sampler.o FormSwep.o Filter.o BiQuad.o Envelope.o ADSR.o OnePole.o Moog.o
|
||||
$(CC) -o Moogy Stk.o WvIn.o WaveLoop.o WvOut.o RtWvOut.o RtAudio.o Instrmnt.o Sampler.o FormSwep.o Filter.o BiQuad.o Envelope.o ADSR.o OnePole.o Moog.o Moogy.cpp $(LIBRARY) $(INCLUDE)
|
||||
68
projects/examples/Makefile.in
Normal file
68
projects/examples/Makefile.in
Normal file
@@ -0,0 +1,68 @@
|
||||
### STK examples Makefile - for various flavors of unix
|
||||
|
||||
PROGRAMS = sine play record io tcpIn tcpOut Moogy
|
||||
RM = /bin/rm
|
||||
SRC_PATH = ../../src
|
||||
OBJECT_PATH = @object_path@
|
||||
vpath %.o $(OBJECT_PATH)
|
||||
|
||||
INCLUDE = @include@
|
||||
ifeq ($(strip $(INCLUDE)), )
|
||||
INCLUDE = ../../include
|
||||
endif
|
||||
vpath %.h $(INCLUDE)
|
||||
|
||||
CC = @CXX@
|
||||
DEFS = @byte_order@
|
||||
DEFS += @debug@
|
||||
CFLAGS = @cflags@
|
||||
CFLAGS += @warn@ -I$(INCLUDE)
|
||||
LIBRARY = @LIBS@
|
||||
LIBRARY += @frameworks@
|
||||
|
||||
REALTIME = @realtime@
|
||||
ifeq ($(REALTIME),yes)
|
||||
DEFS += @sound_api@
|
||||
DEFS += @midiator@
|
||||
endif
|
||||
|
||||
RAWWAVES = @rawwaves@
|
||||
ifeq ($(strip $(RAWWAVES)), )
|
||||
RAWWAVES = ../../rawwaves/
|
||||
endif
|
||||
DEFS += -DRAWWAVE_PATH=\"$(RAWWAVES)\"
|
||||
|
||||
%.o : $(SRC_PATH)/%.cpp
|
||||
$(CC) $(CFLAGS) $(DEFS) -c $(<) -o $(OBJECT_PATH)/$@
|
||||
|
||||
all : $(PROGRAMS)
|
||||
|
||||
$(OBJECTS) : Stk.h
|
||||
|
||||
clean :
|
||||
-rm $(OBJECT_PATH)/*.o
|
||||
-rm $(PROGRAMS)
|
||||
|
||||
strip :
|
||||
strip $(PROGRAMS)
|
||||
|
||||
play: play.cpp Stk.o WvIn.o WvOut.o RtWvOut.o RtAudio.o
|
||||
$(CC) $(CFLAGS) $(DEFS) -o play play.cpp $(OBJECT_PATH)/Stk.o $(OBJECT_PATH)/WvIn.o $(OBJECT_PATH)/WvOut.o $(OBJECT_PATH)/RtWvOut.o $(OBJECT_PATH)/RtAudio.o $(LIBRARY)
|
||||
|
||||
record: record.cpp Stk.o WvIn.o WvOut.o RtWvIn.o RtAudio.o
|
||||
$(CC) $(CFLAGS) $(DEFS) -o record record.cpp $(OBJECT_PATH)/Stk.o $(OBJECT_PATH)/WvIn.o $(OBJECT_PATH)/WvOut.o $(OBJECT_PATH)/RtWvIn.o $(OBJECT_PATH)/RtAudio.o $(LIBRARY)
|
||||
|
||||
sine: sine.cpp Stk.o WvIn.o WvOut.o WaveLoop.o
|
||||
$(CC) $(CFLAGS) $(DEFS) -o sine sine.cpp $(OBJECT_PATH)/Stk.o $(OBJECT_PATH)/WvIn.o $(OBJECT_PATH)/WvOut.o $(OBJECT_PATH)/WaveLoop.o $(LIBRARY)
|
||||
|
||||
io: io.cpp Stk.o RtAudio.o RtDuplex.o
|
||||
$(CC) $(CFLAGS) $(DEFS) -o io io.cpp $(OBJECT_PATH)/Stk.o $(OBJECT_PATH)/RtAudio.o $(OBJECT_PATH)/RtDuplex.o $(LIBRARY)
|
||||
|
||||
tcpIn: tcpIn.cpp Stk.o WvIn.o TcpWvIn.o WvOut.o RtWvOut.o RtAudio.o Socket.o Thread.o
|
||||
$(CC) $(CFLAGS) $(DEFS) -o tcpIn tcpIn.cpp $(OBJECT_PATH)/Stk.o $(OBJECT_PATH)/WvIn.o $(OBJECT_PATH)/Socket.o $(OBJECT_PATH)/Thread.o $(OBJECT_PATH)/TcpWvIn.o $(OBJECT_PATH)/WvOut.o $(OBJECT_PATH)/RtWvOut.o $(OBJECT_PATH)/RtAudio.o $(LIBRARY)
|
||||
|
||||
tcpOut: tcpOut.cpp Stk.o WvIn.o WvOut.o TcpWvOut.o Socket.o Thread.o
|
||||
$(CC) $(CFLAGS) $(DEFS) -o tcpOut tcpOut.cpp $(OBJECT_PATH)/Stk.o $(OBJECT_PATH)/WvIn.o $(OBJECT_PATH)/WvOut.o $(OBJECT_PATH)/Socket.o $(OBJECT_PATH)/Thread.o $(OBJECT_PATH)/TcpWvOut.o $(LIBRARY)
|
||||
|
||||
Moogy: Moogy.cpp Stk.o WvIn.o WaveLoop.o WvOut.o RtWvOut.o RtAudio.o Instrmnt.o Sampler.o FormSwep.o Filter.o BiQuad.o Envelope.o ADSR.o OnePole.o Moog.o
|
||||
$(CC) $(CFLAGS) $(DEFS) -o Moogy Moogy.cpp $(OBJECT_PATH)/Stk.o $(OBJECT_PATH)/WvIn.o $(OBJECT_PATH)/WaveLoop.o $(OBJECT_PATH)/WvOut.o $(OBJECT_PATH)/RtWvOut.o $(OBJECT_PATH)/RtAudio.o $(OBJECT_PATH)/Instrmnt.o $(OBJECT_PATH)/Sampler.o $(OBJECT_PATH)/FormSwep.o $(OBJECT_PATH)/Filter.o $(OBJECT_PATH)/BiQuad.o $(OBJECT_PATH)/Envelope.o $(OBJECT_PATH)/ADSR.o $(OBJECT_PATH)/OnePole.o $(OBJECT_PATH)/Moog.o $(LIBRARY)
|
||||
@@ -1,43 +1,43 @@
|
||||
/******************************************/
|
||||
/*
|
||||
A very basic example program which
|
||||
demonstrates how to play STK's Moog
|
||||
instrument.
|
||||
|
||||
By Gary P. Scavone, 2001.
|
||||
Thanks to Dirk Heise for the suggestion.
|
||||
|
||||
This particular program uses the Moog
|
||||
class, though any Instrmnt subclass will
|
||||
work. If you use a different instrument,
|
||||
however, you may need to update the O_FILES
|
||||
dependencies in the Makefile to successfully
|
||||
compile it.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "WvOut.h"
|
||||
#include "RtWvOut.h"
|
||||
#include "Instrmnt.h"
|
||||
#include "Moog.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Instrmnt* instrument = new Moog();
|
||||
RtWvOut* output = new RtWvOut(1);
|
||||
|
||||
// Start the instrument with note number 60 and
|
||||
// a normalized velocity of 0.9.
|
||||
instrument->noteOn(70, 0.9);
|
||||
|
||||
// Run the instrument for 80000/SRATE seconds.
|
||||
MY_FLOAT *vector = new MY_FLOAT[16];
|
||||
for (int i=0; i<80000; i++) {
|
||||
output->tick(instrument->tick());
|
||||
}
|
||||
|
||||
delete vector;
|
||||
delete output;
|
||||
delete instrument;
|
||||
return 0;
|
||||
}
|
||||
/******************************************/
|
||||
/*
|
||||
A very basic example program which
|
||||
demonstrates how to play STK's Moog
|
||||
instrument.
|
||||
|
||||
By Gary P. Scavone, 2001.
|
||||
Thanks to Dirk Heise for the suggestion.
|
||||
|
||||
This particular program uses the Moog
|
||||
class, though any Instrmnt subclass will
|
||||
work. If you use a different instrument,
|
||||
however, you may need to update the O_FILES
|
||||
dependencies in the Makefile to successfully
|
||||
compile it.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "WvOut.h"
|
||||
#include "RtWvOut.h"
|
||||
#include "Instrmnt.h"
|
||||
#include "Moog.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Instrmnt* instrument = new Moog();
|
||||
RtWvOut* output = new RtWvOut(1);
|
||||
|
||||
// Start the instrument with note number 60 and
|
||||
// a normalized velocity of 0.9.
|
||||
instrument->noteOn(70, 0.9);
|
||||
|
||||
// Run the instrument for 80000/SRATE seconds.
|
||||
MY_FLOAT *vector = new MY_FLOAT[16];
|
||||
for (int i=0; i<80000; i++) {
|
||||
output->tick(instrument->tick());
|
||||
}
|
||||
|
||||
delete vector;
|
||||
delete output;
|
||||
delete instrument;
|
||||
return 0;
|
||||
}
|
||||
|
||||
0
projects/examples/Release/.placeholder
Normal file
0
projects/examples/Release/.placeholder
Normal file
@@ -1,87 +1,92 @@
|
||||
/******************************************/
|
||||
/*
|
||||
Example program for realtime input/output
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This program reads N channels of realtime
|
||||
audio input for a specified amount of time
|
||||
and immediately play them back in realtime
|
||||
(duplex mode). This program also demonstrates
|
||||
the use of FIFO scheduling priority. To be
|
||||
run with such priority, the program must be
|
||||
set suid (chmod +s) and owned by root.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "RtDuplex.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(__OS_LINUX_) || defined(__OS_IRIX__)
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
void usage(void) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
printf("\nuseage: io N time \n");
|
||||
printf(" where N = number of channels,\n");
|
||||
printf(" and time = the amount of time to run (in seconds).\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
// Minimal command-line checking.
|
||||
if (argc != 3) usage();
|
||||
|
||||
unsigned int channels = (unsigned int) atoi(argv[1]);
|
||||
float time = atof(argv[2]);
|
||||
|
||||
// Open the realtime duplex device.
|
||||
RtDuplex *inout = 0;
|
||||
try {
|
||||
inout = new RtDuplex(channels, Stk::sampleRate(), 0, RT_BUFFER_SIZE, 10);
|
||||
}
|
||||
catch (StkError &) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#if defined(__OS_LINUX__) || defined(__OS_IRIX__)
|
||||
// Set schedulling priority to SCHED_FIFO.
|
||||
struct sched_param p;
|
||||
int min, max, priority;
|
||||
|
||||
if (!getuid() || !geteuid()) {
|
||||
min=sched_get_priority_min(SCHED_FIFO);
|
||||
max=sched_get_priority_max(SCHED_FIFO);
|
||||
priority=min+(max-min)/2;
|
||||
p.sched_priority=priority;
|
||||
if (sched_setscheduler(0, SCHED_FIFO, &p)==-1) {
|
||||
fprintf(stderr, "\nCould not activate scheduling with priority %d\n", priority);
|
||||
}
|
||||
seteuid(getuid());
|
||||
}
|
||||
#endif
|
||||
|
||||
// Here's the runtime loop
|
||||
unsigned long i, counter = 0;
|
||||
MY_FLOAT *newFrame = new MY_FLOAT[channels];
|
||||
const MY_FLOAT *lastFrame = inout->lastFrame();
|
||||
unsigned long samples = (unsigned long) (time * Stk::sampleRate());
|
||||
while ( counter < samples ) {
|
||||
for ( i=0; i<channels; i++ )
|
||||
newFrame[i] = lastFrame[i];
|
||||
lastFrame = inout->tickFrame( newFrame );
|
||||
counter++;
|
||||
#if defined(__OS_LINUX__) || defined(__OS_IRIX__)
|
||||
if ( counter % 1024 == 0 )
|
||||
sched_yield();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Clean up
|
||||
delete [] newFrame;
|
||||
delete inout;
|
||||
return 0;
|
||||
}
|
||||
/******************************************/
|
||||
/*
|
||||
Example program for realtime input/output
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This program reads N channels of realtime
|
||||
audio input for a specified amount of time
|
||||
and immediately play them back in realtime
|
||||
(duplex mode). This program also demonstrates
|
||||
the use of FIFO scheduling priority. To be
|
||||
run with such priority, the program must be
|
||||
set suid (chmod +s) and owned by root.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "RtDuplex.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(__OS_LINUX_) || defined(__OS_IRIX__)
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
void usage(void) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
printf("\nuseage: io N time \n");
|
||||
printf(" where N = number of channels,\n");
|
||||
printf(" and time = the amount of time to run (in seconds).\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
// Minimal command-line checking.
|
||||
if (argc != 3) usage();
|
||||
|
||||
unsigned int channels = (unsigned int) atoi(argv[1]);
|
||||
float time = atof(argv[2]);
|
||||
|
||||
// If you want to change the default sample rate (set in Stk.h), do
|
||||
// it before instantiating any objects! If the sample rate is
|
||||
// specified in the command line, it will override this setting.
|
||||
Stk::setSampleRate( 44100.0 );
|
||||
|
||||
// Open the realtime duplex device.
|
||||
RtDuplex *inout = 0;
|
||||
try {
|
||||
inout = new RtDuplex(channels, Stk::sampleRate(), 0, RT_BUFFER_SIZE, 10);
|
||||
}
|
||||
catch (StkError &) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#if defined(__OS_LINUX__) || defined(__OS_IRIX__)
|
||||
// Set schedulling priority to SCHED_FIFO.
|
||||
struct sched_param p;
|
||||
int min, max, priority;
|
||||
|
||||
if (!getuid() || !geteuid()) {
|
||||
min=sched_get_priority_min(SCHED_FIFO);
|
||||
max=sched_get_priority_max(SCHED_FIFO);
|
||||
priority=min+(max-min)/2;
|
||||
p.sched_priority=priority;
|
||||
if (sched_setscheduler(0, SCHED_FIFO, &p)==-1) {
|
||||
fprintf(stderr, "\nCould not activate scheduling with priority %d\n", priority);
|
||||
}
|
||||
seteuid(getuid());
|
||||
}
|
||||
#endif
|
||||
|
||||
// Here's the runtime loop
|
||||
unsigned long i, counter = 0;
|
||||
MY_FLOAT *newFrame = new MY_FLOAT[channels];
|
||||
const MY_FLOAT *lastFrame = inout->lastFrame();
|
||||
unsigned long samples = (unsigned long) (time * Stk::sampleRate());
|
||||
while ( counter < samples ) {
|
||||
for ( i=0; i<channels; i++ )
|
||||
newFrame[i] = lastFrame[i];
|
||||
lastFrame = inout->tickFrame( newFrame );
|
||||
counter++;
|
||||
#if defined(__OS_LINUX__) || defined(__OS_IRIX__)
|
||||
if ( counter % 1024 == 0 )
|
||||
sched_yield();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Clean up
|
||||
delete [] newFrame;
|
||||
delete inout;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
/******************************************/
|
||||
/*
|
||||
Example program to play an N channel
|
||||
soundfile.
|
||||
|
||||
This program will load WAV, SND, AIF, and
|
||||
MAT-file formatted files of various data
|
||||
types. If the audio system does not support
|
||||
the number of channels or sample rate of
|
||||
the soundfile, the program will stop.
|
||||
|
||||
By Gary P. Scavone, 2000 - 2002.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "RtWvOut.h"
|
||||
#include "WvIn.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void usage(void) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
printf("\nuseage: play file <rate>\n");
|
||||
printf(" where file = the file to play,\n");
|
||||
printf(" and rate = an optional playback rate.\n");
|
||||
printf(" (default = 1.0, can be negative)\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Minimal command-line checking.
|
||||
if (argc < 2 || argc > 3) usage();
|
||||
|
||||
// Initialize our WvIn/WvOut pointers.
|
||||
RtWvOut *output = 0;
|
||||
WvIn *input = 0;
|
||||
|
||||
// Try to load the soundfile.
|
||||
try {
|
||||
input = new WvIn( (char *)argv[1] );
|
||||
}
|
||||
catch (StkError &) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Set the global STK sample rate to the file rate.
|
||||
Stk::setSampleRate( input->getFileRate() );
|
||||
|
||||
// Set input read rate.
|
||||
float rate = 1.0;
|
||||
if ( argc == 3 ) rate = atof(argv[2]);
|
||||
input->setRate( rate );
|
||||
|
||||
// Find out how many channels we have.
|
||||
int channels = input->getChannels();
|
||||
|
||||
// Define and open the realtime output device
|
||||
try {
|
||||
output = new RtWvOut( channels, Stk::sampleRate(), 0, 512, 4 );
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Here's the runtime loop.
|
||||
while (!input->isFinished()) {
|
||||
output->tickFrame( input->tickFrame() );
|
||||
}
|
||||
|
||||
cleanup:
|
||||
delete input;
|
||||
delete output;
|
||||
return 0;
|
||||
}
|
||||
/******************************************/
|
||||
/*
|
||||
Example program to play an N channel
|
||||
soundfile.
|
||||
|
||||
This program will load WAV, SND, AIF, and
|
||||
MAT-file formatted files of various data
|
||||
types. If the audio system does not support
|
||||
the number of channels or sample rate of
|
||||
the soundfile, the program will stop.
|
||||
|
||||
By Gary P. Scavone, 2000 - 2002.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "RtWvOut.h"
|
||||
#include "WvIn.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void usage(void) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
printf("\nuseage: play file <rate>\n");
|
||||
printf(" where file = the file to play,\n");
|
||||
printf(" and rate = an optional playback rate.\n");
|
||||
printf(" (default = 1.0, can be negative)\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Minimal command-line checking.
|
||||
if (argc < 2 || argc > 3) usage();
|
||||
|
||||
// Initialize our WvIn/WvOut pointers.
|
||||
RtWvOut *output = 0;
|
||||
WvIn *input = 0;
|
||||
|
||||
// Try to load the soundfile.
|
||||
try {
|
||||
input = new WvIn( argv[1] );
|
||||
}
|
||||
catch (StkError &) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Set the global STK sample rate to the file rate.
|
||||
Stk::setSampleRate( input->getFileRate() );
|
||||
|
||||
// Set input read rate.
|
||||
float rate = 1.0;
|
||||
if ( argc == 3 ) rate = atof(argv[2]);
|
||||
input->setRate( rate );
|
||||
|
||||
// Find out how many channels we have.
|
||||
int channels = input->getChannels();
|
||||
|
||||
// Define and open the realtime output device
|
||||
try {
|
||||
output = new RtWvOut( channels, Stk::sampleRate(), 0, 512, 4 );
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Here's the runtime loop.
|
||||
while (!input->isFinished()) {
|
||||
output->tickFrame( input->tickFrame() );
|
||||
}
|
||||
|
||||
cleanup:
|
||||
delete input;
|
||||
delete output;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,70 +1,70 @@
|
||||
/******************************************/
|
||||
/*
|
||||
Example program to record N channels of data
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This program is currently written to read
|
||||
from a realtime audio input device and to
|
||||
write to a WAV output file. However, it
|
||||
is simple to replace the FILE_TYPE specifier
|
||||
to WvOut with another file type.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "RtWvIn.h"
|
||||
#include "WvOut.h"
|
||||
|
||||
void usage(void) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
printf("\nuseage: record N file time fs \n");
|
||||
printf(" where N = number of channels,\n");
|
||||
printf(" file = the .wav file to create,\n");
|
||||
printf(" time = the amount of time to record (in seconds),\n");
|
||||
printf(" and fs = the sample rate.\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// minimal command-line checking
|
||||
if (argc != 5) usage();
|
||||
|
||||
int channels = (int) atoi(argv[1]);
|
||||
float sample_rate = atof(argv[4]);
|
||||
float time = atof(argv[3]);
|
||||
long samples, i;
|
||||
|
||||
// Set the global sample rate.
|
||||
Stk::setSampleRate( sample_rate );
|
||||
|
||||
// Initialize our WvIn/WvOut pointers.
|
||||
RtWvIn *input = 0;
|
||||
WvOut *output = 0;
|
||||
|
||||
// Open the realtime input device
|
||||
try {
|
||||
input = new RtWvIn(channels);
|
||||
}
|
||||
catch (StkError &) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Open the soundfile for output.
|
||||
try {
|
||||
output = new WvOut(argv[2], channels, WvOut::WVOUT_WAV);
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Here's the runtime loop
|
||||
samples = (long) (time * Stk::sampleRate());
|
||||
for ( i=0; i<samples; i++ )
|
||||
output->tickFrame( input->tickFrame() );
|
||||
|
||||
cleanup:
|
||||
delete input;
|
||||
delete output;
|
||||
return 0;
|
||||
}
|
||||
/******************************************/
|
||||
/*
|
||||
Example program to record N channels of data
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This program is currently written to read
|
||||
from a realtime audio input device and to
|
||||
write to a WAV output file. However, it
|
||||
is simple to replace the FILE_TYPE specifier
|
||||
to WvOut with another file type.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "RtWvIn.h"
|
||||
#include "WvOut.h"
|
||||
|
||||
void usage(void) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
printf("\nuseage: record N file time fs \n");
|
||||
printf(" where N = number of channels,\n");
|
||||
printf(" file = the .wav file to create,\n");
|
||||
printf(" time = the amount of time to record (in seconds),\n");
|
||||
printf(" and fs = the sample rate.\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// minimal command-line checking
|
||||
if (argc != 5) usage();
|
||||
|
||||
int channels = (int) atoi(argv[1]);
|
||||
float sample_rate = atof(argv[4]);
|
||||
float time = atof(argv[3]);
|
||||
long samples, i;
|
||||
|
||||
// Set the global sample rate.
|
||||
Stk::setSampleRate( sample_rate );
|
||||
|
||||
// Initialize our WvIn/WvOut pointers.
|
||||
RtWvIn *input = 0;
|
||||
WvOut *output = 0;
|
||||
|
||||
// Open the realtime input device
|
||||
try {
|
||||
input = new RtWvIn(channels);
|
||||
}
|
||||
catch (StkError &) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Open the soundfile for output.
|
||||
try {
|
||||
output = new WvOut(argv[2], channels, WvOut::WVOUT_WAV);
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Here's the runtime loop
|
||||
samples = (long) (time * Stk::sampleRate());
|
||||
for ( i=0; i<samples; i++ )
|
||||
output->tickFrame( input->tickFrame() );
|
||||
|
||||
cleanup:
|
||||
delete input;
|
||||
delete output;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
# A simple Tcl/Tk example script
|
||||
|
||||
# Set initial control values
|
||||
set pitch 64.0
|
||||
set press 64.0
|
||||
set outID "stdout"
|
||||
|
||||
# Configure main window
|
||||
wm title . "A Simple GUI"
|
||||
wm iconname . "simple"
|
||||
. config -bg black
|
||||
|
||||
# Configure a "note-on" button
|
||||
frame .noteOn -bg black
|
||||
|
||||
button .noteOn.on -text NoteOn -bg grey66 -command { noteOn $pitch $press }
|
||||
pack .noteOn.on -side left -padx 5
|
||||
pack .noteOn
|
||||
|
||||
# Configure sliders
|
||||
frame .slider -bg black
|
||||
|
||||
scale .slider.pitch -from 0 -to 128 -length 200 \
|
||||
-command {changePitch } -variable pitch \
|
||||
-orient horizontal -label "MIDI Note Number" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
|
||||
pack .slider.pitch -padx 10 -pady 10
|
||||
pack .slider -side left
|
||||
|
||||
# Bind an X windows "close" event with the Exit routine
|
||||
bind . <Destroy> +myExit
|
||||
|
||||
proc myExit {} {
|
||||
global pitch outID
|
||||
puts $outID [format "NoteOff 0.0 1 %f 127" $pitch ]
|
||||
flush $outID
|
||||
puts $outID [format "ExitProgram"]
|
||||
flush $outID
|
||||
close $outID
|
||||
exit
|
||||
}
|
||||
|
||||
proc noteOn {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOn 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
}
|
||||
|
||||
proc changePitch {value} {
|
||||
global outID
|
||||
puts $outID [format "PitchBend 0.0 1 %.3f" $value]
|
||||
flush $outID
|
||||
}
|
||||
# A simple Tcl/Tk example script
|
||||
|
||||
# Set initial control values
|
||||
set pitch 64.0
|
||||
set press 64.0
|
||||
set outID "stdout"
|
||||
|
||||
# Configure main window
|
||||
wm title . "A Simple GUI"
|
||||
wm iconname . "simple"
|
||||
. config -bg black
|
||||
|
||||
# Configure a "note-on" button
|
||||
frame .noteOn -bg black
|
||||
|
||||
button .noteOn.on -text NoteOn -bg grey66 -command { noteOn $pitch $press }
|
||||
pack .noteOn.on -side left -padx 5
|
||||
pack .noteOn
|
||||
|
||||
# Configure sliders
|
||||
frame .slider -bg black
|
||||
|
||||
scale .slider.pitch -from 0 -to 128 -length 200 \
|
||||
-command {changePitch } -variable pitch \
|
||||
-orient horizontal -label "MIDI Note Number" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
|
||||
pack .slider.pitch -padx 10 -pady 10
|
||||
pack .slider -side left
|
||||
|
||||
# Bind an X windows "close" event with the Exit routine
|
||||
bind . <Destroy> +myExit
|
||||
|
||||
proc myExit {} {
|
||||
global pitch outID
|
||||
puts $outID [format "NoteOff 0.0 1 %f 127" $pitch ]
|
||||
flush $outID
|
||||
puts $outID [format "ExitProgram"]
|
||||
flush $outID
|
||||
close $outID
|
||||
exit
|
||||
}
|
||||
|
||||
proc noteOn {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOn 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
}
|
||||
|
||||
proc changePitch {value} {
|
||||
global outID
|
||||
puts $outID [format "PitchChange 0.0 1 %.3f" $value]
|
||||
flush $outID
|
||||
}
|
||||
|
||||
@@ -1,96 +1,96 @@
|
||||
/******************************************/
|
||||
/*
|
||||
Example program to write N sine tones to
|
||||
an N channel soundfile.
|
||||
|
||||
By default, the program will write an
|
||||
N channel WAV file. However, it is
|
||||
simple to change the file type argument
|
||||
in the WvOut constructor.
|
||||
|
||||
By Gary P. Scavone, 2000 - 2002.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "WaveLoop.h"
|
||||
#include "WvOut.h"
|
||||
#include <stdlib.h>
|
||||
#include <iostream.h>
|
||||
|
||||
void usage(void) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
printf("\nuseage: sine N file time fs\n");
|
||||
printf(" where N = number of channels (sines),\n");
|
||||
printf(" file = the .wav file to create,\n");
|
||||
printf(" time = the amount of time to record (in seconds),\n");
|
||||
printf(" and fs = the sample rate (in Hz).\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
float base_freq = 220.0;
|
||||
int samples;
|
||||
int i;
|
||||
|
||||
// Minimal command-line checking.
|
||||
if (argc != 5) usage();
|
||||
|
||||
int channels = (int) atoi(argv[1]);
|
||||
double time = atof(argv[3]);
|
||||
double srate = atof(argv[4]);
|
||||
|
||||
// Initialize our object and data pointers.
|
||||
WvOut *output = 0;
|
||||
MY_FLOAT *vector = 0;
|
||||
WaveLoop **oscs = (WaveLoop **) malloc( channels * sizeof(WaveLoop *) );
|
||||
for (i=0; i<channels; i++) oscs[i] = 0;
|
||||
|
||||
// If you want to change the default sample rate (set in Stk.h), do
|
||||
// it before instantiating any objects!!
|
||||
Stk::setSampleRate( srate );
|
||||
|
||||
// Define and load the rawwave file(s) ... the path is critical.
|
||||
try {
|
||||
for (i=0; i<channels; i++)
|
||||
oscs[i] = new WaveLoop( "../../rawwaves/sinewave.raw", TRUE );
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Set oscillator frequency(ies) here ... somewhat random.
|
||||
for (i=0; i<channels; i++)
|
||||
oscs[i]->setFrequency( base_freq + i*(45.0) );
|
||||
|
||||
// Define and open the soundfile for output. Other file
|
||||
// format options include: WVOUT_SND, WVOUT_AIF, WVOUT_MAT,
|
||||
// and WVOUT_RAW. Other data type options include:
|
||||
// STK_SINT8, STK_SINT32, STK_FLOAT32, and STK_FLOAT64.
|
||||
try {
|
||||
output = new WvOut( argv[2], channels, WvOut::WVOUT_WAV, Stk::STK_SINT16 );
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Here's the runtime loop
|
||||
samples = (int) ( time * Stk::sampleRate() );
|
||||
vector = (MY_FLOAT *) new MY_FLOAT[channels];
|
||||
for ( i=0; i<samples; i++ ) {
|
||||
for (int j=0; j<channels; j++) {
|
||||
vector[j] = oscs[j]->tick();
|
||||
}
|
||||
output->tickFrame(vector);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
for (i=0; i<channels; i++)
|
||||
delete oscs[i];
|
||||
free(oscs);
|
||||
delete [] vector;
|
||||
delete output;
|
||||
return 0;
|
||||
}
|
||||
/******************************************/
|
||||
/*
|
||||
Example program to write N sine tones to
|
||||
an N channel soundfile.
|
||||
|
||||
By default, the program will write an
|
||||
N channel WAV file. However, it is
|
||||
simple to change the file type argument
|
||||
in the WvOut constructor.
|
||||
|
||||
By Gary P. Scavone, 2000 - 2002.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "WaveLoop.h"
|
||||
#include "WvOut.h"
|
||||
#include <stdlib.h>
|
||||
#include <iostream.h>
|
||||
|
||||
void usage(void) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
printf("\nuseage: sine N file time fs\n");
|
||||
printf(" where N = number of channels (sines),\n");
|
||||
printf(" file = the .wav file to create,\n");
|
||||
printf(" time = the amount of time to record (in seconds),\n");
|
||||
printf(" and fs = the sample rate (in Hz).\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
float base_freq = 220.0;
|
||||
int samples;
|
||||
int i;
|
||||
|
||||
// Minimal command-line checking.
|
||||
if (argc != 5) usage();
|
||||
|
||||
int channels = (int) atoi(argv[1]);
|
||||
double time = atof(argv[3]);
|
||||
double srate = atof(argv[4]);
|
||||
|
||||
// Initialize our object and data pointers.
|
||||
WvOut *output = 0;
|
||||
MY_FLOAT *vector = 0;
|
||||
WaveLoop **oscs = (WaveLoop **) malloc( channels * sizeof(WaveLoop *) );
|
||||
for (i=0; i<channels; i++) oscs[i] = 0;
|
||||
|
||||
// If you want to change the default sample rate (set in Stk.h), do
|
||||
// it before instantiating any objects!!
|
||||
Stk::setSampleRate( srate );
|
||||
|
||||
// Define and load the rawwave file(s) ... the path is critical.
|
||||
try {
|
||||
for (i=0; i<channels; i++)
|
||||
oscs[i] = new WaveLoop( "../../rawwaves/sinewave.raw", TRUE );
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Set oscillator frequency(ies) here ... somewhat random.
|
||||
for (i=0; i<channels; i++)
|
||||
oscs[i]->setFrequency( base_freq + i*(45.0) );
|
||||
|
||||
// Define and open the soundfile for output. Other file
|
||||
// format options include: WVOUT_SND, WVOUT_AIF, WVOUT_MAT,
|
||||
// and WVOUT_RAW. Other data type options include:
|
||||
// STK_SINT8, STK_SINT32, STK_FLOAT32, and STK_FLOAT64.
|
||||
try {
|
||||
output = new WvOut( argv[2], channels, WvOut::WVOUT_WAV, Stk::STK_SINT16 );
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Here's the runtime loop
|
||||
samples = (int) ( time * Stk::sampleRate() );
|
||||
vector = (MY_FLOAT *) new MY_FLOAT[channels];
|
||||
for ( i=0; i<samples; i++ ) {
|
||||
for (int j=0; j<channels; j++) {
|
||||
vector[j] = oscs[j]->tick();
|
||||
}
|
||||
output->tickFrame(vector);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
for (i=0; i<channels; i++)
|
||||
delete oscs[i];
|
||||
free(oscs);
|
||||
delete [] vector;
|
||||
delete output;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "../../include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__LITTLE_ENDIAN__" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__LITTLE_ENDIAN__" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -65,7 +65,7 @@ LINK32=link.exe
|
||||
# PROP Intermediate_Dir "debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__LITTLE_ENDIAN__" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__LITTLE_ENDIAN__" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
||||
@@ -1,78 +1,78 @@
|
||||
/******************************************/
|
||||
/*
|
||||
Example program to read N channels of audio
|
||||
data that are streamed over a TCP network
|
||||
connection.
|
||||
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This program is currently written to play
|
||||
the input data in realtime. However, it
|
||||
is simple to replace the instance of
|
||||
RtWvOut with WvOut for writing to a
|
||||
soundfile.
|
||||
|
||||
The streamed data format is assumed to be
|
||||
signed 16-bit integers. However, both
|
||||
TcpWvIn and TcpWvOut can be initialized
|
||||
to read/write any of the defined STK_FORMATs.
|
||||
|
||||
The class TcpWvIn sets up a socket server
|
||||
and waits for a connection. Therefore,
|
||||
this program needs to be started before
|
||||
the streaming client. This program will
|
||||
terminate when the socket connection is
|
||||
closed.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "TcpWvIn.h"
|
||||
#include "RtWvOut.h"
|
||||
|
||||
void usage(void) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
printf("\nuseage: tcpIn N fs \n");
|
||||
printf(" where N = number of channels,\n");
|
||||
printf(" and fs = the data sample rate.\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Minimal command-line checking.
|
||||
if (argc != 3) usage();
|
||||
|
||||
Stk::setSampleRate( atof(argv[2]) );
|
||||
int channels = (int) atoi(argv[1]);
|
||||
|
||||
// Initialize the object pointers.
|
||||
RtWvOut *output = 0;
|
||||
TcpWvIn *input = 0;
|
||||
|
||||
// Instantiate the TcpWvIn object.
|
||||
try {
|
||||
input = new TcpWvIn();
|
||||
input->listen( channels, Stk::STK_SINT16 );
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Open the realtime output device.
|
||||
try {
|
||||
output = new RtWvOut(channels);
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Here's the runtime loop.
|
||||
while ( input->isConnected() )
|
||||
output->tickFrame( input->tickFrame() );
|
||||
|
||||
cleanup:
|
||||
delete input;
|
||||
delete output;
|
||||
return 0;
|
||||
}
|
||||
/******************************************/
|
||||
/*
|
||||
Example program to read N channels of audio
|
||||
data that are streamed over a TCP network
|
||||
connection.
|
||||
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This program is currently written to play
|
||||
the input data in realtime. However, it
|
||||
is simple to replace the instance of
|
||||
RtWvOut with WvOut for writing to a
|
||||
soundfile.
|
||||
|
||||
The streamed data format is assumed to be
|
||||
signed 16-bit integers. However, both
|
||||
TcpWvIn and TcpWvOut can be initialized
|
||||
to read/write any of the defined STK_FORMATs.
|
||||
|
||||
The class TcpWvIn sets up a socket server
|
||||
and waits for a connection. Therefore,
|
||||
this program needs to be started before
|
||||
the streaming client. This program will
|
||||
terminate when the socket connection is
|
||||
closed.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "TcpWvIn.h"
|
||||
#include "RtWvOut.h"
|
||||
|
||||
void usage(void) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
printf("\nuseage: tcpIn N fs \n");
|
||||
printf(" where N = number of channels,\n");
|
||||
printf(" and fs = the data sample rate.\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Minimal command-line checking.
|
||||
if (argc != 3) usage();
|
||||
|
||||
Stk::setSampleRate( atof(argv[2]) );
|
||||
int channels = (int) atoi(argv[1]);
|
||||
|
||||
// Initialize the object pointers.
|
||||
RtWvOut *output = 0;
|
||||
TcpWvIn *input = 0;
|
||||
|
||||
// Instantiate the TcpWvIn object.
|
||||
try {
|
||||
input = new TcpWvIn();
|
||||
input->listen( channels, Stk::STK_SINT16 );
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Open the realtime output device.
|
||||
try {
|
||||
output = new RtWvOut(channels);
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Here's the runtime loop.
|
||||
while ( input->isConnected() )
|
||||
output->tickFrame( input->tickFrame() );
|
||||
|
||||
cleanup:
|
||||
delete input;
|
||||
delete output;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,86 +1,86 @@
|
||||
/******************************************/
|
||||
/*
|
||||
Example program to output N channels of audio
|
||||
data over a TCP network socket connection.
|
||||
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This program will load a specified WAV,
|
||||
SND, AIFF, STK RAW, or MAT-file formatted
|
||||
file. The output data format is set for
|
||||
signed 16-bit integers. However, it is
|
||||
easy to change the TcpWvOut setting to
|
||||
any of the other defined STK_FORMATs.
|
||||
If using tcpIn, it will be necessary to
|
||||
change the expected data format there
|
||||
as well.
|
||||
|
||||
The class StrmWvOut first attempts to
|
||||
establish a socket connection to a socket
|
||||
server running on port 2006. Therefore,
|
||||
this program needs to be started AFTER the
|
||||
streaming server.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "WvIn.h"
|
||||
#include "TcpWvOut.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void usage(void) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
printf("\nuseage: tcpOut file host <rate>\n");
|
||||
printf(" where file = the file to load,\n");
|
||||
printf(" host = the hostname where the receiving\n");
|
||||
printf(" application is running.\n");
|
||||
printf(" and rate = an optional playback rate for the file.\n");
|
||||
printf(" (default = 1.0, can be negative)\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Minimal command-line checking.
|
||||
if (argc < 3 || argc > 4) usage();
|
||||
|
||||
// Initialize the object pointers.
|
||||
TcpWvOut *output = 0;
|
||||
WvIn *input = 0;
|
||||
|
||||
// Load the file.
|
||||
try {
|
||||
input = new WvIn( (char *)argv[1] );
|
||||
}
|
||||
catch (StkError &) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Set the global STK sample rate to the file rate.
|
||||
Stk::setSampleRate( input->getFileRate() );
|
||||
|
||||
// Set input read rate.
|
||||
double rate = 1.0;
|
||||
if ( argc == 4 ) rate = atof(argv[3]);
|
||||
input->setRate( rate );
|
||||
|
||||
// Find out how many channels we have.
|
||||
int channels = input->getChannels();
|
||||
|
||||
// Define and open the output device
|
||||
try {
|
||||
output = new TcpWvOut(2006, (char *)argv[2], channels, Stk::STK_SINT16);
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Here's the runtime loop
|
||||
while ( !input->isFinished() )
|
||||
output->tickFrame( input->tickFrame() );
|
||||
|
||||
cleanup:
|
||||
delete input;
|
||||
delete output;
|
||||
return 0;
|
||||
}
|
||||
/******************************************/
|
||||
/*
|
||||
Example program to output N channels of audio
|
||||
data over a TCP network socket connection.
|
||||
|
||||
by Gary P. Scavone, 2000
|
||||
|
||||
This program will load a specified WAV,
|
||||
SND, AIFF, STK RAW, or MAT-file formatted
|
||||
file. The output data format is set for
|
||||
signed 16-bit integers. However, it is
|
||||
easy to change the TcpWvOut setting to
|
||||
any of the other defined STK_FORMATs.
|
||||
If using tcpIn, it will be necessary to
|
||||
change the expected data format there
|
||||
as well.
|
||||
|
||||
The class StrmWvOut first attempts to
|
||||
establish a socket connection to a socket
|
||||
server running on port 2006. Therefore,
|
||||
this program needs to be started AFTER the
|
||||
streaming server.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#include "WvIn.h"
|
||||
#include "TcpWvOut.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void usage(void) {
|
||||
// Error function in case of incorrect command-line
|
||||
// argument specifications.
|
||||
printf("\nuseage: tcpOut file host <rate>\n");
|
||||
printf(" where file = the file to load,\n");
|
||||
printf(" host = the hostname where the receiving\n");
|
||||
printf(" application is running.\n");
|
||||
printf(" and rate = an optional playback rate for the file.\n");
|
||||
printf(" (default = 1.0, can be negative)\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Minimal command-line checking.
|
||||
if (argc < 3 || argc > 4) usage();
|
||||
|
||||
// Initialize the object pointers.
|
||||
TcpWvOut *output = 0;
|
||||
WvIn *input = 0;
|
||||
|
||||
// Load the file.
|
||||
try {
|
||||
input = new WvIn( (char *)argv[1] );
|
||||
}
|
||||
catch (StkError &) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Set the global STK sample rate to the file rate.
|
||||
Stk::setSampleRate( input->getFileRate() );
|
||||
|
||||
// Set input read rate.
|
||||
double rate = 1.0;
|
||||
if ( argc == 4 ) rate = atof(argv[3]);
|
||||
input->setRate( rate );
|
||||
|
||||
// Find out how many channels we have.
|
||||
int channels = input->getChannels();
|
||||
|
||||
// Define and open the output device
|
||||
try {
|
||||
output = new TcpWvOut(2006, (char *)argv[2], channels, Stk::STK_SINT16);
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Here's the runtime loop
|
||||
while ( !input->isFinished() )
|
||||
output->tickFrame( input->tickFrame() );
|
||||
|
||||
cleanup:
|
||||
delete input;
|
||||
delete output;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "../../include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /D "__LITTLE_ENDIAN__" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /D "__LITTLE_ENDIAN__" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -66,7 +66,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /D "__LITTLE_ENDIAN__" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /D "__LITTLE_ENDIAN__" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
||||
Reference in New Issue
Block a user