aboutsummaryrefslogtreecommitdiff
path: root/speexin~.c
diff options
context:
space:
mode:
Diffstat (limited to 'speexin~.c')
-rw-r--r--speexin~.c558
1 files changed, 282 insertions, 276 deletions
diff --git a/speexin~.c b/speexin~.c
index 310e028..60a441f 100644
--- a/speexin~.c
+++ b/speexin~.c
@@ -25,7 +25,7 @@
/* be found at http://speex.sourceforge.net. */
/* */
/* ---------------------------------------------------------------------------- */
-
+
#include <m_pd.h>
#include <g_canvas.h>
@@ -89,11 +89,11 @@ void speexin_closesocket(int fd)
#ifndef _WIN32
if ( close(fd) < 0 )
{
- perror( "close" );
+ perror( "close" );
}
else
{
- post( "speexin~ : closed socket : %d", fd );
+ post( "speexin~ : closed socket : %d", fd );
}
#endif
#ifdef _WIN32
@@ -103,33 +103,33 @@ void speexin_closesocket(int fd)
}
int setsocketoptions(int sockfd)
-{
- int sockopt = 1;
- if (setsockopt(sockfd, SOL_TCP, TCP_NODELAY, (const char*) &sockopt, sizeof(int)) < 0)
- {
- post("speexin~ : setsockopt TCP_NODELAY failed");
- perror( "setsockopt" );
- return -1;
- }
- else
- {
- post("speexin~ : TCP_NODELAY set");
- }
-
+{
+ int sockopt = 1;
+ if (setsockopt(sockfd, SOL_TCP, TCP_NODELAY, (const char*) &sockopt, sizeof(int)) < 0)
+ {
+ post("speexin~ : setsockopt TCP_NODELAY failed");
+ perror( "setsockopt" );
+ return -1;
+ }
+ else
+ {
+ post("speexin~ : TCP_NODELAY set");
+ }
+
#ifdef _WIN32
- sockopt = 1;
- if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(int)) < 0)
- {
- post("speexin~ : setsockopt SO_REUSEADDR failed");
- perror( "setsockopt" );
- return -1;
- }
- else
- {
- post("speexin~ : setsockopt SO_REUSEADDR done.");
- }
+ sockopt = 1;
+ if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(int)) < 0)
+ {
+ post("speexin~ : setsockopt SO_REUSEADDR failed");
+ perror( "setsockopt" );
+ return -1;
+ }
+ else
+ {
+ post("speexin~ : setsockopt SO_REUSEADDR done.");
+ }
#endif
- return 0;
+ return 0;
}
@@ -139,62 +139,62 @@ static t_class *speexin_class;
typedef struct _speexin
{
- t_object x_obj;
- t_int x_socket;
- t_outlet *x_connectionip;
- t_int x_serversocket;
- t_int x_samplerate;
-
- /* Speex stuff */
- SpeexBits x_bits; /* bits packing structure */
- void *x_decstate; /* decoder state */
- t_int x_framesize; /* frame size */
- t_int x_mode; /* Narrow or Wide Band */
- int x_quality; /* encoding quality ( 0 to 10 ) */
-
- t_int x_inpackets; /* number of packets received */
- t_int x_dpacket; /* displayed packet in status bar */
- t_int x_packetsize; /* size of the packets */
- t_int x_pblocks; /* processed blocks */
- t_int x_graphic; /* indicates if we show a graphic bar */
-
- void *x_inbuffer; /* accumulation buffer for incoming speex frames */
- t_int x_inwritepos; /* accumulation buffer for incoming speex frames */
- t_int x_encsize;
- t_int x_inbuffersize;
-
- t_float *x_outbuffer; /* buffer to store audio decoded data */
- t_int x_oinp;
- t_int x_ooutp;
- t_int x_outunread;
- t_int x_outbuffersize;
- t_float *x_decchunk;
-
- t_canvas *x_canvas;
-
- t_int x_stream; /* indicates if a stream is connected ( meaning correct input flow ) */
- t_int x_newstream; /* at first, the stream must provide enough data to start */
+ t_object x_obj;
+ t_int x_socket;
+ t_outlet *x_connectionip;
+ t_int x_serversocket;
+ t_int x_samplerate;
+
+ /* Speex stuff */
+ SpeexBits x_bits; /* bits packing structure */
+ void *x_decstate; /* decoder state */
+ t_int x_framesize; /* frame size */
+ t_int x_mode; /* Narrow or Wide Band */
+ int x_quality; /* encoding quality ( 0 to 10 ) */
+
+ t_int x_inpackets; /* number of packets received */
+ t_int x_dpacket; /* displayed packet in status bar */
+ t_int x_packetsize; /* size of the packets */
+ t_int x_pblocks; /* processed blocks */
+ t_int x_graphic; /* indicates if we show a graphic bar */
+
+ void *x_inbuffer; /* accumulation buffer for incoming speex frames */
+ t_int x_inwritepos; /* accumulation buffer for incoming speex frames */
+ t_int x_encsize;
+ t_int x_inbuffersize;
+
+ t_float *x_outbuffer; /* buffer to store audio decoded data */
+ t_int x_oinp;
+ t_int x_ooutp;
+ t_int x_outunread;
+ t_int x_outbuffersize;
+ t_float *x_decchunk;
+
+ t_canvas *x_canvas;
+
+ t_int x_stream; /* indicates if a stream is connected ( meaning correct input flow ) */
+ t_int x_newstream; /* at first, the stream must provide enough data to start */
} t_speexin;
void speexin_tilde_speex_init(t_speexin *x)
{
- int ret;
- int pf=1;
+ int ret;
+ int pf=1;
speex_bits_init(&x->x_bits);
switch ( x->x_mode )
{
- case SPEEX_NB_MODE :
+ case SPEEX_NB_MODE :
x->x_decstate = speex_decoder_init(&speex_nb_mode);
break;
- case SPEEX_WB_MODE :
+ case SPEEX_WB_MODE :
x->x_decstate = speex_decoder_init(&speex_wb_mode);
break;
-
- default :
+
+ default :
error( "speexin~ : severe error : decoding scheme is unknown" );
break;
}
@@ -209,145 +209,145 @@ void speexin_tilde_speex_init(t_speexin *x)
static void speexin_decode_input(t_speexin *x)
{
- int i;
- int alength = 0;
- static char out[8192];
- signed short int *p = (signed short int *) out;
- int pbytes;
- int ret;
- int flength = 0;
-
- if ( x->x_encsize > 0 )
- {
-
- while ( x->x_encsize > *(char *)(x->x_inbuffer) )
+ int i;
+ int alength = 0;
+ static char out[8192];
+ signed short int *p = (signed short int *) out;
+ int pbytes;
+ int ret;
+ int flength = 0;
+
+ if ( x->x_encsize > 0 )
{
- flength = *(char *)(x->x_inbuffer );
+ while ( x->x_encsize > *(char *)(x->x_inbuffer) )
+ {
+
+ flength = *(char *)(x->x_inbuffer );
- // post( "speexin~ : reading bits from 1 to : %d", flength+1 );
- speex_bits_read_from(&x->x_bits, x->x_inbuffer+1, flength);
+ // post( "speexin~ : reading bits from 1 to : %d", flength+1 );
+ speex_bits_read_from(&x->x_bits, x->x_inbuffer+1, flength);
#ifdef DATADEBUG
- {
- t_int si;
-
- printf( "speexin~ : decoding : " );
- for ( si=0; si<flength; si++ )
- {
- printf( "%d ", *(char *)(x->x_inbuffer+1+si) );
- }
- printf( "\n" );
- }
+ {
+ t_int si;
+
+ printf( "speexin~ : decoding : " );
+ for ( si=0; si<flength; si++ )
+ {
+ printf( "%d ", *(char *)(x->x_inbuffer+1+si) );
+ }
+ printf( "\n" );
+ }
#endif
- {
- t_int sp=0, rp=0;
-
- speex_decode(x->x_decstate, &x->x_bits, x->x_decchunk);
-
- while( sp < x->x_framesize )
- {
- rp=(x->x_oinp+sp)%x->x_outbuffersize;
- // if ( rp == x->x_outbuffersize - 1 ) post( "speexin~ : write at the end of audio buffer" );
- // post( "speexin~ : sp=%d : rp=%d", sp, rp );
- x->x_outbuffer[ rp ] = x->x_decchunk[sp++];
- }
- x->x_oinp = rp+1;
- }
- x->x_outunread += x->x_framesize;
- memcpy( x->x_inbuffer, x->x_inbuffer+flength+1, x->x_inbuffersize-flength-1 );
- x->x_encsize -= flength+1;
- x->x_inwritepos -= flength+1;
+ {
+ t_int sp=0, rp=0;
+
+ speex_decode(x->x_decstate, &x->x_bits, x->x_decchunk);
+
+ while( sp < x->x_framesize )
+ {
+ rp=(x->x_oinp+sp)%x->x_outbuffersize;
+ // if ( rp == x->x_outbuffersize - 1 ) post( "speexin~ : write at the end of audio buffer" );
+ // post( "speexin~ : sp=%d : rp=%d", sp, rp );
+ x->x_outbuffer[ rp ] = x->x_decchunk[sp++];
+ }
+ x->x_oinp = rp+1;
+ }
+ x->x_outunread += x->x_framesize;
+ memcpy( x->x_inbuffer, x->x_inbuffer+flength+1, x->x_inbuffersize-flength-1 );
+ x->x_encsize -= flength+1;
+ x->x_inwritepos -= flength+1;
- }
+ }
- }
+ }
- if ( x->x_graphic && glist_isvisible( x->x_canvas ) )
- {
- /* update graphical read status */
- if ( x->x_inpackets != x->x_dpacket )
- {
- char color[32];
- int minpackets = ( MIN_AUDIO_INPUT/x->x_framesize)-2; // audio loop has eaten some already
+ if ( x->x_graphic && glist_isvisible( x->x_canvas ) )
+ {
+ /* update graphical read status */
+ if ( x->x_inpackets != x->x_dpacket )
+ {
+ char color[32];
+ int minpackets = ( MIN_AUDIO_INPUT/x->x_framesize)-2; // audio loop has eaten some already
sys_vgui(".x%lx.c delete rectangle %xSTATUS\n", x->x_canvas, x );
sys_vgui(".x%lx.c delete line %xTHRESHOLD\n", x->x_canvas, x );
if ( x->x_outunread > 0 )
{
- t_int width;
-
- if ( x->x_inpackets < (MIN_AUDIO_INPUT/x->x_framesize)/2 )
- {
- strcpy( color, "red" );
- }
- else
- {
- strcpy( color, "lightgreen" );
- }
- width = rtext_width( glist_findrtext( (t_glist*)x->x_canvas, (t_text *)x ) );
- sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill %s -tags %xSTATUS\n",
- x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-BARHEIGHT-1,
- x->x_obj.te_xpix+(x->x_inpackets*x->x_packetsize*width)/INPUT_BUFFER_SIZE,
- x->x_obj.te_ypix - 1, color, x );
- sys_vgui(".x%lx.c create line %d %d %d %d -fill red -tags %xTHRESHOLD\n",
- x->x_canvas, x->x_obj.te_xpix+(minpackets*x->x_packetsize*width)/INPUT_BUFFER_SIZE,
- x->x_obj.te_ypix-BARHEIGHT-1,
- x->x_obj.te_xpix+(minpackets*x->x_packetsize*width)/INPUT_BUFFER_SIZE,
- x->x_obj.te_ypix-1, x );
- x->x_dpacket = x->x_inpackets;
+ t_int width;
+
+ if ( x->x_inpackets < (MIN_AUDIO_INPUT/x->x_framesize)/2 )
+ {
+ strcpy( color, "red" );
+ }
+ else
+ {
+ strcpy( color, "lightgreen" );
+ }
+ width = rtext_width( glist_findrtext( (t_glist*)x->x_canvas, (t_text *)x ) );
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill %s -tags %xSTATUS\n",
+ x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-BARHEIGHT-1,
+ x->x_obj.te_xpix+(x->x_inpackets*x->x_packetsize*width)/INPUT_BUFFER_SIZE,
+ x->x_obj.te_ypix - 1, color, x );
+ sys_vgui(".x%lx.c create line %d %d %d %d -fill red -tags %xTHRESHOLD\n",
+ x->x_canvas, x->x_obj.te_xpix+(minpackets*x->x_packetsize*width)/INPUT_BUFFER_SIZE,
+ x->x_obj.te_ypix-BARHEIGHT-1,
+ x->x_obj.te_xpix+(minpackets*x->x_packetsize*width)/INPUT_BUFFER_SIZE,
+ x->x_obj.te_ypix-1, x );
+ x->x_dpacket = x->x_inpackets;
}
- }
+ }
- }
+ }
}
static void speexin_recv(t_speexin *x)
{
- int ret;
+ int ret;
- if ( x->x_inwritepos > x->x_inbuffersize - 1024 )
- {
+ if ( x->x_inwritepos > x->x_inbuffersize - 1024 )
+ {
post( "speexin~ : input buffer is full" );
return;
- }
- if ( ( ret = recv(x->x_socket, (void*) x->x_inbuffer + x->x_inwritepos,
- (size_t)x->x_inbuffersize,
- MSG_NOSIGNAL) ) < 0 )
- {
+ }
+ if ( ( ret = recv(x->x_socket, (void*) x->x_inbuffer + x->x_inwritepos,
+ (size_t)x->x_inbuffersize,
+ MSG_NOSIGNAL) ) < 0 )
+ {
post( "speexin~ : receive error" );
perror( "recv" );
- return;
- }
- else
- {
- // post( "speexin~ : received %d bytes at %d on %d ( up to %d)",
+ return;
+ }
+ else
+ {
+ // post( "speexin~ : received %d bytes at %d on %d ( up to %d)",
// ret, x->x_inwritepos, x->x_socket,
// x->x_inbuffersize );
- if ( ret == 0 )
+ if ( ret == 0 )
{
- post( "speexin~ : closing connection ( s=%d )", x->x_socket );
- speexin_closesocket(x->x_socket);
- x->x_socket = -1;
- sys_vgui(".x%lx.c delete rectangle %xPBAR\n", x->x_canvas, x );
- sys_vgui(".x%lx.c delete line %xTHRESHOLD\n", x->x_canvas, x );
- sys_vgui(".x%lx.c delete rectangle %xSTATUS\n", x->x_canvas, x );
- outlet_symbol( x->x_connectionip, gensym("") );
+ post( "speexin~ : closing connection ( s=%d )", x->x_socket );
+ speexin_closesocket(x->x_socket);
+ x->x_socket = -1;
+ sys_vgui(".x%lx.c delete rectangle %xPBAR\n", x->x_canvas, x );
+ sys_vgui(".x%lx.c delete line %xTHRESHOLD\n", x->x_canvas, x );
+ sys_vgui(".x%lx.c delete rectangle %xSTATUS\n", x->x_canvas, x );
+ outlet_symbol( x->x_connectionip, gensym("") );
}
else
- {
- x->x_inpackets++;
+ {
+ x->x_inpackets++;
}
x->x_encsize += ret;
x->x_inwritepos += ret;
-
+
speexin_decode_input(x);
- }
+ }
}
static void speexin_acceptconnection(t_speexin *x)
@@ -358,15 +358,17 @@ static void speexin_acceptconnection(t_speexin *x)
int fd = accept(x->x_serversocket, (struct sockaddr*)&incomer_address, &sockaddrl );
post("speexin~: accepted incomer : %d.", fd );
- if (fd < 0) {
- post("speexin~: accept failed");
- return;
+ if (fd < 0)
+ {
+ post("speexin~: accept failed");
+ return;
}
- if (x->x_socket > 0) {
- post("speexin~: the source has changed to %s ( new socket = %d ).",
- inet_ntoa( incomer_address.sin_addr ), fd );
- speexin_closesocket(x->x_socket);
+ if (x->x_socket > 0)
+ {
+ post("speexin~: the source has changed to %s ( new socket = %d ).",
+ inet_ntoa( incomer_address.sin_addr ), fd );
+ speexin_closesocket(x->x_socket);
}
x->x_socket = fd;
@@ -375,12 +377,12 @@ static void speexin_acceptconnection(t_speexin *x)
if ( x->x_graphic && glist_isvisible( x->x_canvas ) )
{
- t_int width;
-
- width = rtext_width( glist_findrtext( (t_glist*)x->x_canvas, (t_text *)x ) );
- sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill lightblue -tags %xPBAR\n",
- x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-BARHEIGHT-1,
- x->x_obj.te_xpix + width, x->x_obj.te_ypix - 1, x );
+ t_int width;
+
+ width = rtext_width( glist_findrtext( (t_glist*)x->x_canvas, (t_text *)x ) );
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill lightblue -tags %xPBAR\n",
+ x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-BARHEIGHT-1,
+ x->x_obj.te_xpix + width, x->x_obj.te_ypix - 1, x );
}
x->x_stream = 0;
x->x_newstream = 1;
@@ -398,8 +400,8 @@ static int speexin_startservice(t_speexin* x, int portno)
if (sockfd < 0)
{
- sys_sockerror("socket");
- return (0);
+ sys_sockerror("socket");
+ return (0);
}
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
@@ -411,118 +413,122 @@ static int speexin_startservice(t_speexin* x, int portno)
setsocketoptions(sockfd);
/* name the socket */
- if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0) {
- sys_sockerror("bind");
- speexin_closesocket(sockfd);
- return (0);
+ if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
+ {
+ sys_sockerror("bind");
+ speexin_closesocket(sockfd);
+ return (0);
}
- if (listen(sockfd, 5) < 0) {
- sys_sockerror("listen");
- speexin_closesocket(sockfd);
+ if (listen(sockfd, 5) < 0)
+ {
+ sys_sockerror("listen");
+ speexin_closesocket(sockfd);
}
- else
+ else
{
- x->x_serversocket = sockfd;
- sys_addpollfn(x->x_serversocket, (t_fdpollfn)speexin_acceptconnection, x);
+ x->x_serversocket = sockfd;
+ sys_addpollfn(x->x_serversocket, (t_fdpollfn)speexin_acceptconnection, x);
}
-
+
return 1;
}
static void speexin_free(t_speexin *x)
{
- post( "speexin~ : free %x", x );
- if (x->x_serversocket > 0) {
+ post( "speexin~ : free %x", x );
+ if (x->x_serversocket > 0)
+ {
post( "speexin~ : closing server socket" );
- speexin_closesocket(x->x_serversocket);
+ speexin_closesocket(x->x_serversocket);
x->x_serversocket = -1;
- }
- if (x->x_socket > 0) {
+ }
+ if (x->x_socket > 0)
+ {
post( "speexin~ : closing socket" );
speexin_closesocket(x->x_socket);
x->x_socket = -1;
- }
- if ( x->x_inbuffer ) freebytes( x->x_inbuffer, x->x_inbuffersize );
- if ( x->x_outbuffer ) freebytes( x->x_outbuffer, x->x_outbuffersize*sizeof(t_float) );
- if ( x->x_decchunk ) freebytes(x->x_decchunk, x->x_framesize*sizeof(t_float));
+ }
+ if ( x->x_inbuffer ) freebytes( x->x_inbuffer, x->x_inbuffersize );
+ if ( x->x_outbuffer ) freebytes( x->x_outbuffer, x->x_outbuffersize*sizeof(t_float) );
+ if ( x->x_decchunk ) freebytes(x->x_decchunk, x->x_framesize*sizeof(t_float));
}
static t_int *speexin_perform(t_int *w)
{
- t_speexin *x = (t_speexin*) (w[1]);
- t_float *out = (t_float *)(w[2]);
- t_int n = (int)(w[3]);
- t_int bsize = n;
- t_int ret;
- t_int i = 0;
- t_int j = 0;
- t_int sp = 0;
- t_int sratio;
-
- // samplerate is supposed to be above 16kHz, thus sratio>1
- if ( x->x_mode == SPEEX_NB_MODE )
- {
- sratio = x->x_samplerate / 8000;
- }
- else
- {
- sratio = x->x_samplerate / 16000;
- }
- // post( "speexin~ : ratio : %d", sratio );
-
- memset( out, 0x0, n*sizeof(t_float ) );
-
- sp = 0;
- while( sp < n )
- {
- if ( ( ( x->x_outunread > MIN_AUDIO_INPUT ) && x->x_newstream ) || // wait the buffer to load
- ( x->x_stream ) // check that the stream provides enough data
- )
- {
+ t_speexin *x = (t_speexin*) (w[1]);
+ t_float *out = (t_float *)(w[2]);
+ t_int n = (int)(w[3]);
+ t_int bsize = n;
+ t_int ret;
+ t_int i = 0;
+ t_int j = 0;
+ t_int sp = 0;
+ t_int sratio;
+
+ // samplerate is supposed to be above 16kHz, thus sratio>1
+ if ( x->x_mode == SPEEX_NB_MODE )
+ {
+ sratio = x->x_samplerate / 8000;
+ }
+ else
+ {
+ sratio = x->x_samplerate / 16000;
+ }
+ // post( "speexin~ : ratio : %d", sratio );
+
+ memset( out, 0x0, n*sizeof(t_float ) );
+
+ sp = 0;
+ while( sp < n )
+ {
+ if ( ( ( x->x_outunread > MIN_AUDIO_INPUT ) && x->x_newstream ) || // wait the buffer to load
+ ( x->x_stream ) // check that the stream provides enough data
+ )
+ {
if ( x->x_newstream )
{
- x->x_newstream = 0;
- x->x_stream = 1;
+ x->x_newstream = 0;
+ x->x_stream = 1;
}
/* resampling */
for ( j=0; j<sratio; j++ )
- {
- *(out+sp)=*(x->x_outbuffer+x->x_ooutp)/8000; // input has been scaled
- //*(x->x_outbuffer+x->x_ooutp)=0.0; // data read, now zeroed
- sp++;
- if ( sp >= n ) break;
+ {
+ *(out+sp)=*(x->x_outbuffer+x->x_ooutp)/8000; // input has been scaled
+ //*(x->x_outbuffer+x->x_ooutp)=0.0; // data read, now zeroed
+ sp++;
+ if ( sp >= n ) break;
}
x->x_ooutp = (x->x_ooutp + 1)%x->x_outbuffersize;
// if ( x->x_ooutp == x->x_outbuffersize - 1 ) post( "speexin~ : end of audio buffer" );
x->x_outunread-=1;
- }
- else
- {
+ }
+ else
+ {
for ( j=0; j<sratio; j++ )
- {
- *(out+sp)=0.0;
- sp++;
- if ( sp >= n ) break;
+ {
+ *(out+sp)=0.0;
+ sp++;
+ if ( sp >= n ) break;
}
- }
- }
- x->x_pblocks++;
-
- if ( ( x->x_outunread <= MIN_AUDIO_INPUT/10 ) && ( x->x_stream ) )
- {
- // post( "speexin~ : stream lost (too little input)" );
- x->x_stream = 0;
- x->x_newstream = 1; // waiting for a new stream
- }
-
- if ( x->x_pblocks == x->x_framesize/bsize )
- {
+ }
+ }
+ x->x_pblocks++;
+
+ if ( ( x->x_outunread <= MIN_AUDIO_INPUT/10 ) && ( x->x_stream ) )
+ {
+ // post( "speexin~ : stream lost (too little input)" );
+ x->x_stream = 0;
+ x->x_newstream = 1; // waiting for a new stream
+ }
+
+ if ( x->x_pblocks == x->x_framesize/bsize )
+ {
x->x_inpackets--;
x->x_pblocks = 0;
- }
+ }
- return (w+4);
+ return (w+4);
}
static void speexin_dsp(t_speexin *x, t_signal **sp)
@@ -535,22 +541,22 @@ static void *speexin_new(t_floatarg fportno, t_floatarg fdographics)
{
t_speexin *x;
int i;
-
+
if ( fportno < 0 || fportno > 65535 )
{
- post( "speexin~ : error : wrong portnumber : %d", (int)fportno );
- return NULL;
+ post( "speexin~ : error : wrong portnumber : %d", (int)fportno );
+ return NULL;
}
if ( ((int)fdographics != 0) && ((int)fdographics != 1.) )
{
- post( "speexin~ : error : constructor : speexin~ <portnumber> [graphic flag = 0 | 1 ] ( got = %f)", fdographics );
- return NULL;
+ post( "speexin~ : error : constructor : speexin~ <portnumber> [graphic flag = 0 | 1 ] ( got = %f)", fdographics );
+ return NULL;
}
x = (t_speexin *)pd_new(speexin_class);
outlet_new(&x->x_obj, &s_signal);
x->x_connectionip = outlet_new(&x->x_obj, &s_symbol);
-
+
x->x_serversocket = -1;
x->x_socket = -1;
x->x_inpackets = 0;
@@ -562,7 +568,7 @@ static void *speexin_new(t_floatarg fportno, t_floatarg fdographics)
x->x_canvas = canvas_getcurrent();
x->x_inbuffersize = INPUT_BUFFER_SIZE;
- x->x_outbuffersize = OUTPUT_BUFFER_SIZE;
+ x->x_outbuffersize = OUTPUT_BUFFER_SIZE;
x->x_inbuffer = (char*) getbytes( x->x_inbuffersize );
memset( x->x_inbuffer, 0x0, INPUT_BUFFER_SIZE );
x->x_outbuffer = (t_float*) getbytes( x->x_outbuffersize*sizeof(t_float) );
@@ -570,14 +576,14 @@ static void *speexin_new(t_floatarg fportno, t_floatarg fdographics)
if ( !x->x_inbuffer || !x->x_outbuffer )
{
- post( "speexin~ : could not allocate buffers." );
- return NULL;
+ post( "speexin~ : could not allocate buffers." );
+ return NULL;
}
x->x_encsize = 0;
x->x_oinp = 0;
x->x_ooutp = 0;
-
+
ztout.tv_sec = 0;
ztout.tv_usec = 0;
@@ -603,9 +609,9 @@ static void *speexin_new(t_floatarg fportno, t_floatarg fdographics)
void speexin_tilde_setup(void)
{
verbose(0, speexin_version );
- speexin_class = class_new(gensym("speexin~"),
- (t_newmethod) speexin_new, (t_method) speexin_free,
- sizeof(t_speexin), CLASS_NOINLET, A_DEFFLOAT, A_DEFFLOAT, A_NULL);
+ speexin_class = class_new(gensym("speexin~"),
+ (t_newmethod) speexin_new, (t_method) speexin_free,
+ sizeof(t_speexin), CLASS_NOINLET, A_DEFFLOAT, A_DEFFLOAT, A_NULL);
class_addmethod(speexin_class, nullfn, gensym("signal"), 0);
class_addmethod(speexin_class, (t_method) speexin_dsp, gensym("dsp"), 0);