mirror of
https://github.com/thestk/stk
synced 2026-02-05 00:56:14 +00:00
Version 3.1
This commit is contained in:
committed by
Stephen Sinclair
parent
868787a5f9
commit
4b6500d3de
@@ -18,12 +18,12 @@ RM = /bin/rm
|
||||
ifeq ($(OS),IRIX) # These are for SGI
|
||||
INSTR = effects
|
||||
CC = CC -O2 -D__OS_IRIX_ # -g -fullwarn -D__SGI_CC__
|
||||
LIBRARY = -L/usr/sgitcl/lib -laudio -lmd -lm
|
||||
LIBRARY = -L/usr/sgitcl/lib -laudio -lmd -lm -lpthread
|
||||
endif
|
||||
|
||||
ifeq ($(OS),Linux) # These are for Linux
|
||||
INSTR = effects
|
||||
CC = g++ -O3 -D__OS_Linux_ # -g
|
||||
CC = g++ -O3 -Wall -D__OS_Linux_ # -g
|
||||
LIBRARY = -lpthread -lm
|
||||
endif
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ int numStrings = 0;
|
||||
int notDone = 1;
|
||||
char **inputString;
|
||||
|
||||
void errorfun(void) {
|
||||
void usage(void) {
|
||||
/* Error function in case of incorrect command-line argument specifications */
|
||||
printf("\nuseage: effects flag \n");
|
||||
printf(" where flag = -ip for realtime SKINI input by pipe\n");
|
||||
@@ -28,7 +28,7 @@ void errorfun(void) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void main(int argc,char *argv[])
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
MY_FLOAT inSample = 0.0;
|
||||
MY_FLOAT lastSample = 0.0;
|
||||
@@ -36,12 +36,12 @@ void main(int argc,char *argv[])
|
||||
long i, synlength;
|
||||
int type, j, outOne = 0, effect = 0, useSocket = 0;
|
||||
|
||||
if (argc != 2) errorfun();
|
||||
if (argc != 2) usage();
|
||||
|
||||
if (!strcmp(argv[1],"-is") )
|
||||
useSocket = 1;
|
||||
else if (strcmp(argv[1],"-ip")) {
|
||||
errorfun();
|
||||
usage();
|
||||
}
|
||||
|
||||
RTDuplex *inout = new RTDuplex(SRATE,1);
|
||||
@@ -85,21 +85,25 @@ void main(int argc,char *argv[])
|
||||
score->parseThis(inputString[outOne]);
|
||||
type = score->getType();
|
||||
if (type > 0) {
|
||||
if (type == __SK_NoteOn_ ) {
|
||||
switch(type) {
|
||||
case __SK_NoteOn_:
|
||||
// check to see if velocity is zero ... really a NoteOff
|
||||
if (( byte3 = score->getByteThree() ) == 0) { // NoteOff
|
||||
envelope->setRate(0.001);
|
||||
envelope->setTarget(0.0);
|
||||
}
|
||||
else { // Really a NoteOn
|
||||
else { // really a NoteOn
|
||||
envelope->setRate(0.001);
|
||||
envelope->setTarget(1.0);
|
||||
}
|
||||
}
|
||||
else if (type == __SK_NoteOff_) {
|
||||
break;
|
||||
|
||||
case __SK_NoteOff_:
|
||||
envelope->setRate(0.001);
|
||||
envelope->setTarget(0.0);
|
||||
}
|
||||
else if (type == __SK_ControlChange_) {
|
||||
break;
|
||||
|
||||
case __SK_ControlChange_:
|
||||
j = (int) score->getByteTwo();
|
||||
byte3 = score->getByteThree();
|
||||
if (j == 20) effect = (int) byte3; // effect change
|
||||
@@ -119,6 +123,7 @@ void main(int argc,char *argv[])
|
||||
else if (j == 23) { // effect1 parameter change
|
||||
chorus->setModDepth(byte3*NORM_7*0.2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
outOne += 1;
|
||||
@@ -156,4 +161,5 @@ void main(int argc,char *argv[])
|
||||
delete envelope;
|
||||
|
||||
printf("effects finished ... goodbye.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
// Thread functions for use with syntmono.
|
||||
//
|
||||
// Gary P. Scavone, 1999.
|
||||
// No mutexes are currently being used when accessing
|
||||
// the global variables shared between these threads
|
||||
// and the main() routine. In a single processor
|
||||
// environment, no problems have resulted from such data
|
||||
// sharing. However, if STK is to be run on a true parallel
|
||||
// processing platform, it is likely that mutexes will be
|
||||
// necessary. While the mutex calls are simple to code, I
|
||||
// am trying to keep the code as generic as possible. A
|
||||
// quick investigation of threads under Windoze indicates
|
||||
// that mutex functionality is not available, at least with
|
||||
// the standard libraries.
|
||||
//
|
||||
// Gary P. Scavone, 2000.
|
||||
|
||||
#include "threads.h"
|
||||
|
||||
#if defined(__STK_REALTIME_)
|
||||
|
||||
#define SERVICE_PORT 2001 // Socket Port ID number
|
||||
// Default STK socket port ID number
|
||||
#define SERVICE_PORT 2001
|
||||
|
||||
// Do OS dependent declarations and includes
|
||||
#if defined(__OS_IRIX_)
|
||||
#include <signal.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
|
||||
pid_t string_thread;
|
||||
|
||||
#elif defined(__OS_Linux_)
|
||||
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
|
||||
#include <pthread.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -39,13 +41,10 @@ unsigned long string_thread;
|
||||
#endif
|
||||
|
||||
|
||||
// The thread function definition protocols are slightly
|
||||
// different under Irix, Linux, and Windoze.
|
||||
#if defined(__OS_IRIX_)
|
||||
// The thread function protocols are slightly different
|
||||
// under Windoze ... but of course!
|
||||
|
||||
void newStringByPipe(void *)
|
||||
|
||||
#elif defined(__OS_Linux_)
|
||||
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
|
||||
|
||||
void *newStringByPipe(void *)
|
||||
|
||||
@@ -86,14 +85,15 @@ void newStringByPipe(void *)
|
||||
// Free inputString.
|
||||
for ( i=0;i<MAX_IN_STRINGS;i++ ) free(inputString[i]);
|
||||
free(inputString);
|
||||
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
#elif defined(__OS_Win_)
|
||||
_endthread();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if defined(__OS_IRIX_)
|
||||
|
||||
void newStringBySocket(void *)
|
||||
|
||||
#elif defined(__OS_Linux_)
|
||||
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
|
||||
|
||||
void *newStringBySocket(void *)
|
||||
|
||||
@@ -113,7 +113,7 @@ void newStringBySocket(void *)
|
||||
fd_set mask, rmask;
|
||||
struct sockaddr_in sockname;
|
||||
char socBuf[STRING_LEN];
|
||||
static struct timeval timeout = {0, 1000}; // one millisecond
|
||||
static struct timeval timeout = {0, 10000}; // ten millisecond
|
||||
|
||||
// Malloc inputString.
|
||||
inputString = (char **) malloc(MAX_IN_STRINGS * sizeof(char *));
|
||||
@@ -163,6 +163,9 @@ void newStringBySocket(void *)
|
||||
|
||||
while (notDone) {
|
||||
rmask = mask;
|
||||
// Need to reset the timeout values because of linux "select" implementation
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 10000; // 0.01 seconds
|
||||
select(maxfd+1, &rmask, (fd_set *)0, (fd_set *)0, &timeout);
|
||||
if (FD_ISSET(soc_id,&rmask)) { // a new connection is available
|
||||
// Accept and service the incoming connection request
|
||||
@@ -232,18 +235,18 @@ void newStringBySocket(void *)
|
||||
free(inputString);
|
||||
|
||||
printf("Socket connection closed.\n");
|
||||
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
#elif defined(__OS_Win_)
|
||||
_endthread();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void startPipeThread()
|
||||
{
|
||||
#if defined(__OS_IRIX_)
|
||||
string_thread = sproc(newStringByPipe, PR_SALL);
|
||||
if (string_thread == -1) {
|
||||
fprintf(stderr, "unable to create input pipe thread ... aborting.\n");
|
||||
exit(0);
|
||||
}
|
||||
#elif defined(__OS_Linux_)
|
||||
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
|
||||
if (pthread_create(&string_thread, NULL, newStringByPipe, NULL)) {
|
||||
fprintf(stderr, "unable to create input pipe thread ... aborting.\n");
|
||||
exit(0);
|
||||
@@ -259,13 +262,7 @@ void startPipeThread()
|
||||
|
||||
void startSocketThread()
|
||||
{
|
||||
#if defined(__OS_IRIX_)
|
||||
string_thread = sproc(newStringBySocket, PR_SALL);
|
||||
if (string_thread == -1) {
|
||||
fprintf(stderr, "unable to create input socket thread...aborting.\n");
|
||||
exit(0);
|
||||
}
|
||||
#elif defined(__OS_Linux_)
|
||||
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
|
||||
if (pthread_create(&string_thread, NULL, newStringBySocket, NULL)) {
|
||||
fprintf(stderr, "unable to create input socket thread...aborting.\n");
|
||||
exit(0);
|
||||
|
||||
@@ -6,12 +6,15 @@
|
||||
|
||||
#define STRING_LEN 60
|
||||
|
||||
/*
|
||||
#if (defined(__STK_REALTIME_) && defined(__OS_IRIX_) )
|
||||
|
||||
void newStringByPipe(void *);
|
||||
void newStringBySocket(void *);
|
||||
|
||||
#elif (defined(__STK_REALTIME_) && defined(__OS_Linux_) )
|
||||
*/
|
||||
#if (defined(__STK_REALTIME_) && (defined(__OS_IRIX_) || defined(__OS_Linux_)))
|
||||
|
||||
void *newStringByPipe(void *);
|
||||
void *newStringBySocket(void *);
|
||||
|
||||
Reference in New Issue
Block a user