Version 4.2.1

This commit is contained in:
Gary Scavone
2009-03-24 23:02:14 -04:00
committed by Stephen Sinclair
parent a6381b9d38
commit 2cbce2d8bd
275 changed files with 8949 additions and 6906 deletions

View File

@@ -1,14 +1,14 @@
### STK demo Makefile - for various flavors of unix
PROGRAMS = demo
PROGRAMS = demo Md2Skini
RM = /bin/rm
SRC_PATH = ../../src
OBJECT_PATH = @object_path@
vpath %.o $(OBJECT_PATH)
OBJECTS = Stk.o Generator.o Noise.o SubNoise.o Envelope.o ADSR.o \
Modulate.o SingWave.o \
WvIn.o WaveLoop.o WvOut.o \
Modulate.o SingWave.o SineWave.o FileRead.o FileWrite.o \
WvIn.o FileWvIn.o WaveLoop.o WvOut.o FileWvOut.o \
Filter.o OneZero.o OnePole.o PoleZero.o TwoZero.o \
BiQuad.o FormSwep.o Delay.o DelayL.o DelayA.o \
Function.o ReedTable.o JetTable.o BowTable.o \
@@ -39,7 +39,7 @@ LIBRARY += @frameworks@
REALTIME = @realtime@
ifeq ($(REALTIME),yes)
OBJECTS += RtMidi.o RtAudio.o Thread.o Mutex.o Socket.o
OBJECTS += RtMidi.o RtAudio.o Thread.o Mutex.o Socket.o TcpServer.o
DEFS += @audio_apis@
endif

View File

@@ -23,10 +23,16 @@ void usage(void) {
std::cout << " With flag = -f <filename>, the output stream is simultaneously\n";
std::cout << " written to the file specified by the optional <filename>\n";
std::cout << " (default = test.ski).\n";
std::cout << " With flag = -c, MIDI control change messages will not be\n";
std::cout << " converted to SKINI-specific named controls.\n";
std::cout << " A MIDI input port can be specified with flag = -p portNumber.\n" << std::endl;
exit(0);
}
#include <signal.h>
static void finish( int ignore ){ std::cout << "Type 'Exit' to quit." << std::endl; }
bool parseSkiniControl = true;
void midiCallback( double deltatime, std::vector< unsigned char > *bytes, void *userData )
{
if ( bytes->size() < 2 ) return;
@@ -35,7 +41,7 @@ void midiCallback( double deltatime, std::vector< unsigned char > *bytes, void *
if ( bytes->at(0) > 239 ) return;
register long type = bytes->at(0) & 0xF0;
register long channel = bytes->at(0) & 0x0F;
register int channel = bytes->at(0) & 0x0F;
register long databyte1 = bytes->at(1);
register long databyte2 = 0;
if ( ( type != 0xC0 ) && ( type != 0xD0 ) ) {
@@ -75,56 +81,63 @@ void midiCallback( double deltatime, std::vector< unsigned char > *bytes, void *
case __SK_ControlChange_:
if ( parseSkiniControl != true ) {
typeName = "ControlChange\t";
goto output;
}
switch( databyte1 ) {
case __SK_PitchChange_:
typeName = "PitchChange\t";
break;
goto output;
case __SK_Volume_:
typeName = "Volume\t";
break;
goto output;
case __SK_ModWheel_:
typeName = "ModWheel\t";
break;
goto output;
case __SK_Breath_:
typeName = "Breath\t\t";
break;
goto output;
case __SK_FootControl_:
typeName = "FootControl\t";
break;
goto output;
case __SK_Portamento_:
typeName = "Portamento\t";
break;
goto output;
case __SK_Balance_:
typeName = "Balance\t";
break;
goto output;
case __SK_Pan_:
typeName = "Pan\t\t";
break;
goto output;
case __SK_Sustain_:
typeName = "Sustain\t";
break;
goto output;
case __SK_Expression_:
typeName = "Expression\t";
break;
goto output;
default:
typeName = "ControlChange\t";
break;
goto output;
}
default:
typeName = "Unknown\t";
typeName = "Unknown\t";
}
output:
FILE *file = (FILE *) userData;
if ( type == 0xC0 || type == 0xD0 || type == 0xE0 ) { // program change, channel pressure, or pitchbend
fprintf( stdout, "%s %.3f %d %.1f\n", typeName.c_str(), 0.0, channel, (float)databyte1 );
@@ -132,9 +145,16 @@ void midiCallback( double deltatime, std::vector< unsigned char > *bytes, void *
fprintf( file, "%s %.3f %d %.1f\n", typeName.c_str(), deltatime, channel, (float)databyte1 );
}
else if ( type == 0xB0 ) { // control change
if ( typeName == "ControlChange\t" ) {
fprintf( stdout, "%s %.3f %d %.1f %.1f\n", typeName.c_str(), 0.0, channel, (float)databyte1, (float)databyte2 );
if ( file != NULL )
fprintf( file, "%s %.3f %d %.1f %.1f\n", typeName.c_str(), deltatime, channel, (float)databyte1, (float)databyte2 );
}
else {
fprintf( stdout, "%s %.3f %d %.1f\n", typeName.c_str(), 0.0, channel, (float)databyte2 );
if ( file != NULL )
fprintf( file, "%s %.3f %d %.1f\n", typeName.c_str(), deltatime, channel, (float)databyte2 );
}
}
else { // noteon, noteoff, aftertouch, and unknown
fprintf( stdout, "%s %.3f %d %.1f %.1f\n", typeName.c_str(), 0.0, channel, (float)databyte1, (float)databyte2 );
@@ -149,6 +169,7 @@ int main( int argc,char *argv[] )
std::string fileName;
RtMidiIn *midiin = 0;
unsigned int port = 0;
std::string input;
if ( argc > 5 ) usage();
@@ -172,6 +193,10 @@ int main( int argc,char *argv[] )
if ( i++ >= argc) usage();
port = (unsigned int) atoi( argv[i] );
break;
case 'c':
parseSkiniControl = false;
break;
default:
usage();
@@ -219,9 +244,15 @@ int main( int argc,char *argv[] )
// We'll ignore sysex, timing, and active sensing messages.
midiin->ignoreTypes( true, true, true );
std::cout << "\nReading MIDI input ... press <enter> to quit.\n";
char input;
std::cin.get(input);
// Install an interrupt handler function.
(void) signal(SIGINT, finish);
std::cout << "\nReading MIDI input ... type 'Exit' to quit.\n";
while ( input != "Exit" && input != "exit" ) {
input.erase();
std::cin >> input;
std::cout << input << std::endl;
}
cleanup:
delete midiin;

View File

@@ -194,6 +194,10 @@ int main( int argc, char *argv[] )
// specified in the command line, it will override this setting.
Stk::setSampleRate( 44100.0 );
// By default, warning messages are not printed. If we want to see
// them, we need to specify that here.
Stk::showWarnings( true );
// Check the command-line arguments for errors and to determine
// the number of WvOut objects to be instantiated (in utilities.cpp).
data.nWvOuts = checkArgs(argc, argv);
@@ -276,12 +280,14 @@ int main( int argc, char *argv[] )
// Shut down the callback and output stream.
#if defined(__STK_REALTIME__)
try {
dac->cancelStreamCallback();
dac->closeStream();
}
catch (RtError& error) {
error.printMessage();
if ( data.realtime ) {
try {
dac->cancelStreamCallback();
dac->closeStream();
}
catch (RtError& error) {
error.printMessage();
}
}
#endif

View File

@@ -159,6 +159,22 @@ SOURCE=..\..\src\Envelope.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\FileRead.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\FileWrite.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\FileWvIn.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\FileWvOut.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\Filter.cpp
# End Source File
# Begin Source File
@@ -323,6 +339,10 @@ SOURCE=..\..\src\Simple.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\SineWave.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\SingWave.cpp
# End Source File
# Begin Source File
@@ -355,6 +375,10 @@ SOURCE=..\..\src\SubNoise.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\TcpServer.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\Thread.cpp
# End Source File
# Begin Source File
@@ -479,6 +503,22 @@ SOURCE=..\..\include\Envelope.h
# End Source File
# Begin Source File
SOURCE=..\..\include\FileRead.h
# End Source File
# Begin Source File
SOURCE=..\..\include\FileWrite.h
# End Source File
# Begin Source File
SOURCE=..\..\include\FileWvIn.h
# End Source File
# Begin Source File
SOURCE=..\..\include\FileWvOut.h
# End Source File
# Begin Source File
SOURCE=..\..\include\Filter.h
# End Source File
# Begin Source File
@@ -643,6 +683,10 @@ SOURCE=..\..\include\Simple.h
# End Source File
# Begin Source File
SOURCE=..\..\include\SineWave.h
# End Source File
# Begin Source File
SOURCE=..\..\include\SingWave.h
# End Source File
# Begin Source File
@@ -675,6 +719,10 @@ SOURCE=..\..\include\SubNoise.h
# End Source File
# Begin Source File
SOURCE=..\..\include\TcpServer.h
# End Source File
# Begin Source File
SOURCE=..\..\include\Thread.h
# End Source File
# Begin Source File

View File

@@ -659,7 +659,7 @@ proc patchChange {value} {
.right.cont4 config -state normal -label "Stick Position"
set preset [expr $value-2400]
if {$preset == 1} {
.right.cont11 config -state normal -label "Vibrato Gain"
.right.cont11 config -state normal -label "Vibrato Rate"
} else {
.right.cont11 config -state disabled -label "Disabled"
}

View File

@@ -176,7 +176,7 @@ proc noteOff {pitchVal pressVal} {
proc patchChange {value} {
global outID preset
if {$preset == 1} {
.right.cont11 config -state normal -label "Vibrato Gain"
.right.cont11 config -state normal -label "Vibrato Rate"
} else {
.right.cont11 config -state disabled -label "Disabled"
}

View File

@@ -128,8 +128,8 @@ void usage(char *function) {
printf(" -im <port> for realtime control input by MIDI (virtual port = 0, default = 1),\n");
#endif
printf(" and Instrument = one of these:\n");
for (i=0;i<NUM_INSTS;i+=8) {
for (j=0;j<8 && (i+j) < NUM_INSTS;j++) {
for ( i=0; i<NUM_INSTS; i+=8 ) {
for ( j=0; j<8 && (i+j)<NUM_INSTS; j++ ) {
printf("%s ",insts[i+j]);
}
printf("\n");
@@ -182,10 +182,10 @@ int checkArgs(int numArgs, char *args[])
}
// Check for multiple flags of the same type
for (i=0; i<=j; i++) {
for ( i=0; i<=j; i++ ) {
w = i+1;
while (w <= j) {
if (flags[0][i] == flags[0][w] && flags[1][i] == flags[1][w] ) {
while (w <= j ) {
if ( flags[0][i] == flags[0][w] && flags[1][i] == flags[1][w] ) {
printf("\nError: Multiple command line flags of the same type specified.\n\n");
usage(args[0]);
}
@@ -203,7 +203,7 @@ int countVoices(int nArgs, char *args[])
{
int i = 2, nInstruments = 1;
while (i < nArgs) {
while ( i < nArgs ) {
if ( strncmp( args[i], "-n", 2) == 0 ) {
if ( i+1 < nArgs && args[i+1][0] != '-' ) {
nInstruments = atoi( args[i+1] );
@@ -218,7 +218,7 @@ int countVoices(int nArgs, char *args[])
bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
{
int i = 2, j = 0;
int i = 2, j = 0, nWvIns = 0;
bool realtime = false;
char fileName[256];
@@ -228,12 +228,14 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
case 'f':
strcpy(fileName,args[++i]);
if ( !messager.setScoreFile( fileName ) ) usage(args[0]);
if ( !messager.setScoreFile( fileName ) ) exit(0);
nWvIns++;
break;
case 'p':
#if defined(__STK_REALTIME__)
if ( !messager.startStdInput() ) usage(args[0]);
if ( !messager.startStdInput() ) exit(0);
nWvIns++;
break;
#else
usage(args[0]);
@@ -244,9 +246,10 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
// Check for an optional socket port argument.
if ((i+1 < numArgs) && args[i+1][0] != '-') {
int port = atoi(args[++i]);
if ( !messager.startSocketInput( port ) ) usage(args[0]);
if ( !messager.startSocketInput( port ) ) exit(0);
}
else if ( !messager.startSocketInput() ) usage(args[0]);
else if ( !messager.startSocketInput() ) exit(0);
nWvIns++;
break;
#else
usage(args[0]);
@@ -257,9 +260,10 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
// Check for an optional MIDI port argument.
if ((i+1 < numArgs) && args[i+1][0] != '-') {
int port = atoi(args[++i]);
if ( !messager.startMidiInput( port-1 ) ) usage(args[0]);
if ( !messager.startMidiInput( port-1 ) ) exit(0);
}
else if ( !messager.startMidiInput() ) usage(args[0]);
else if ( !messager.startMidiInput() ) exit(0);
nWvIns++;
break;
#else
usage(args[0]);
@@ -287,7 +291,7 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
strcpy(fileName,args[i]);
}
else strcpy(fileName,"testwav");
output[j] = new WvOut(fileName, 1, WvOut::WVOUT_WAV );
output[j] = new FileWvOut(fileName, 1, FileWrite::FILE_WAV );
j++;
break;
@@ -297,7 +301,7 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
strcpy(fileName,args[i]);
}
else strcpy(fileName,"testsnd");
output[j] = new WvOut(fileName,1, WvOut::WVOUT_SND);
output[j] = new FileWvOut(fileName,1, FileWrite::FILE_SND);
j++;
break;
@@ -307,7 +311,7 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
strcpy(fileName,args[i]);
}
else strcpy(fileName,"testmat");
output[j] = new WvOut(fileName,1, WvOut::WVOUT_MAT);
output[j] = new FileWvOut(fileName,1, FileWrite::FILE_MAT);
j++;
break;
@@ -317,7 +321,7 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
strcpy(fileName,args[i]);
}
else strcpy(fileName,"testaif");
output[j] = new WvOut(fileName,1, WvOut::WVOUT_AIF );
output[j] = new FileWvOut(fileName,1, FileWrite::FILE_AIF );
j++;
break;
@@ -329,5 +333,14 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
i++;
}
if ( nWvIns == 0 ) {
#if defined(__STK_REALTIME__)
if ( !messager.startStdInput() ) exit(0);
#else
printf("\nError: The -if file input flag must be specified for non-realtime use.\n\n");
usage(args[0]);
#endif
}
return realtime;
}

View File

@@ -3,7 +3,7 @@
// Gary P. Scavone, 1999.
#include "Instrmnt.h"
#include "WvOut.h"
#include "FileWvOut.h"
#include "Messager.h"
int voiceByNumber(int number, Instrmnt **instrument);