aboutsummaryrefslogtreecommitdiff
path: root/pd
diff options
context:
space:
mode:
authorMiller Puckette <millerpuckette@users.sourceforge.net>2004-09-06 19:45:05 +0000
committerMiller Puckette <millerpuckette@users.sourceforge.net>2004-09-06 19:45:05 +0000
commitdad636821f6e7d3ead02c157f308c0ceeba9af3d (patch)
treeaca5bc6404d8f9405ef9731b4a022dffcf9efc64 /pd
parent122576daab6296fb3c8996ab1b721eee433a5ff7 (diff)
Removed files which appear to be unused.
svn path=/trunk/; revision=2009
Diffstat (limited to 'pd')
-rw-r--r--pd/extra/bonk~/README.txt30
-rw-r--r--pd/extra/choice/README.txt12
-rw-r--r--pd/extra/fiddle~/README.txt33
-rw-r--r--pd/portaudio/pa_linux_alsa/blocking_calls.obin1180 -> 0 bytes
-rw-r--r--pd/portaudio/pa_linux_alsa/callback_thread.obin4180 -> 0 bytes
-rw-r--r--pd/portaudio/pablio/pablio_pd.obin3500 -> 0 bytes
-rw-r--r--pd/portaudio/pablio/ringbuffer_pd.obin1824 -> 0 bytes
-rw-r--r--pd/portaudio_v18/VERSION.txt2
-rw-r--r--pd/portaudio_v18/pablio/pablio_pd.c340
-rw-r--r--pd/portaudio_v18/pablio/pablio_pd.h110
-rw-r--r--pd/portaudio_v18/pablio/ringbuffer_pd.c217
-rw-r--r--pd/portaudio_v18/pablio/test_w_saw_pd.c108
-rw-r--r--pd/portmidi_osx/MSP-README.txt3
-rwxr-xr-xpd/src/makefile.mingw133
-rw-r--r--pd/src/makefile.nt.pa19185
-rw-r--r--pd/src/s_audio_alsa.c.old946
16 files changed, 0 insertions, 2119 deletions
diff --git a/pd/extra/bonk~/README.txt b/pd/extra/bonk~/README.txt
deleted file mode 100644
index 6b0017cd..00000000
--- a/pd/extra/bonk~/README.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-Bonk is copyright (C) 1997 Regents of the University of California.
-Permission is granted to use this software for any purpose, commercial
-or noncommercial, as long as this notice is included with all copies.
-
-UC MAKES NO WARRANTY, EXPRESS OR IMPLIED, IN CONNECTION WITH THIS SOFTWARE!
-
-----------------------------------------------------------------------------
-
-This is the README file for the "bonk" percussion detector. This software
-is available from http://man104nfs.ucsd.edu/~mpuckett in versions for
-IRIX 5.x and for NT on Intel boxes.
-
-Bonk will soon be available separately for Max/MSP on Macintoshes.
-
-TO INSTALL FOR IRIX 5.x: download from the Web page, which will give you a
-file named "bonk-x.xx.tar.Z" (where x.xx is the version number). Unpack this
-by typing "zcat bonk-x.xx.tar.Z | tar xf -" which will give you a directory
-named "bonk" containing the source, the object code, and the "help patch."
-
-TO INSTALL FOR NT: download from the Web page, which will give you a file
-named "bonk-x.xx.zip" (where x.xx is the version number). Unpack this by
-typing "unzip bonk-x.xx.zip" to a terminal window which will give you a
-directory named "bonk". The source, the object code, and the "help patch"
-will be there.
-
-Pd currently has no search path facility; the object file (bonk.pd_irix5 or
-bonk.dll) should be copied to the directories containing whatever patches you
-want to use it with.
-
--Miller Puckette (msp@ucsd.edu)
diff --git a/pd/extra/choice/README.txt b/pd/extra/choice/README.txt
deleted file mode 100644
index 3c3ed132..00000000
--- a/pd/extra/choice/README.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-Choice is copyright (C) 1999 Miller Puckette.
-Permission is granted to use this software for any purpose, commercial
-or noncommercial, as long as this notice is included with all copies.
-
-NEITHER THE AUTHORS NOR THEIR EMPLOYERS MAKE ANY WARRANTY, EXPRESS OR IMPLIED,
-IN CONNECTION WITH THIS SOFTWARE!
-
-----------------------------------------------------------------------------
-
-This is the README file for the "choice" object. This software
-is available from http://www.crca.ucsd.edu/~msp as part of the "toys"
-library. - msp@ucsd.edu
diff --git a/pd/extra/fiddle~/README.txt b/pd/extra/fiddle~/README.txt
deleted file mode 100644
index 82d2ad68..00000000
--- a/pd/extra/fiddle~/README.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-Fiddle is copyright (C) 1997 Regents of the University of California.
-Permission is granted to use this software for any noncommercial purpose.
-For commercial licensing contact the UCSD Technology Transfer Office.
-
-UC MAKES NO WARRANTY, EXPRESS OR IMPLIED, IN CONNECTION WITH THIS SOFTWARE!
-
-----------------------------------------------------------------------------
-
-This is the README file for the "fiddle" audio pitch detector. This software
-is available from http://man104nfs.ucsd.edu/~mpuckett in versions for
-IRIX 5.x and for NT on Intel boxes.
-
-Fiddle will soon be available separately for Max/MSP on Macintoshes.
-
-TO INSTALL FOR IRIX 5.x: download from the Web page, which will give you a
-file named "fiddle-x.xx.tar.Z" (where x.xx is the version number). Unpack this
-by typing "zcat fiddle-x.xx.tar.Z | tar xf -" which will give you a directory
-named "fiddle" containing the source, the object code, and the "help patch."
-
-TO INSTALL FOR NT: download from the Web page, which will give you a file
-named "fiddle-x.xx.zip" (where x.xx is the version number). Unpack this by
-typing "unzip fiddle-x.xx.zip" which will give you a directory named "fiddle".
-The source, the object code, and the "help patch" will be there.
-
-Pd currently has no search path facility; the object file (fiddle.pd_irix5 or
-fiddle.dll) should be copied to the directorys containing whatever patches you
-want to use it with.
-
-Please note that the copyright notice on Fiddle is more restrictive than for
-Pd; this is to prevent Fiddle from being incorporated in any commercial product
-that could compete with IRCAM's audio analysis tools.
-
--Miller Puckette (msp@ucsd.edu)
diff --git a/pd/portaudio/pa_linux_alsa/blocking_calls.o b/pd/portaudio/pa_linux_alsa/blocking_calls.o
deleted file mode 100644
index d4bc2108..00000000
--- a/pd/portaudio/pa_linux_alsa/blocking_calls.o
+++ /dev/null
Binary files differ
diff --git a/pd/portaudio/pa_linux_alsa/callback_thread.o b/pd/portaudio/pa_linux_alsa/callback_thread.o
deleted file mode 100644
index a242d490..00000000
--- a/pd/portaudio/pa_linux_alsa/callback_thread.o
+++ /dev/null
Binary files differ
diff --git a/pd/portaudio/pablio/pablio_pd.o b/pd/portaudio/pablio/pablio_pd.o
deleted file mode 100644
index 359a8c49..00000000
--- a/pd/portaudio/pablio/pablio_pd.o
+++ /dev/null
Binary files differ
diff --git a/pd/portaudio/pablio/ringbuffer_pd.o b/pd/portaudio/pablio/ringbuffer_pd.o
deleted file mode 100644
index a348b1ed..00000000
--- a/pd/portaudio/pablio/ringbuffer_pd.o
+++ /dev/null
Binary files differ
diff --git a/pd/portaudio_v18/VERSION.txt b/pd/portaudio_v18/VERSION.txt
deleted file mode 100644
index 350a736a..00000000
--- a/pd/portaudio_v18/VERSION.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Portaudio version 18.1, packaged 03.05.28, downloaded Aug. 1:
--rw------- 1 msp 550130 Aug 1 19:47 portaudio_v18_1.zip
diff --git a/pd/portaudio_v18/pablio/pablio_pd.c b/pd/portaudio_v18/pablio/pablio_pd.c
deleted file mode 100644
index 24b12ff1..00000000
--- a/pd/portaudio_v18/pablio/pablio_pd.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * $Id: pablio_pd.c,v 1.2 2004-02-22 16:21:33 ggeiger Exp $
- * pablio.c
- * Portable Audio Blocking Input/Output utility.
- *
- * Author: Phil Burk, http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * Any person wishing to distribute modifications to the Software is
- * requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
- /* changes by Miller Puckette to support Pd: device selection,
- settable audio buffer size, and settable number of channels.
- LATER also fix it to poll for input and output fifo fill points. */
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include "portaudio.h"
-#include "ringbuffer.h"
-#include "pablio_pd.h" /* MSP */
-#include <string.h>
-
- /* MSP -- FRAMES_PER_BUFFER constant removed */
-static void NPa_Sleep(int n) /* MSP wrapper to check we never stall... */
-{
-#if 0
- fprintf(stderr, "sleep\n");
-#endif
- Pa_Sleep(n);
-}
-
-/************************************************************************/
-/******** Prototypes ****************************************************/
-/************************************************************************/
-
-static int blockingIOCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData );
-static PaError PABLIO_InitFIFO( RingBuffer *rbuf, long numFrames, long bytesPerFrame );
-static PaError PABLIO_TermFIFO( RingBuffer *rbuf );
-
-/************************************************************************/
-/******** Functions *****************************************************/
-/************************************************************************/
-
-/* Called from PortAudio.
- * Read and write data only if there is room in FIFOs.
- */
-static int blockingIOCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- PABLIO_Stream *data = (PABLIO_Stream*)userData;
- long numBytes = data->bytesPerFrame * framesPerBuffer;
- (void) outTime;
-
- /* This may get called with NULL inputBuffer during initial setup. */
- if( inputBuffer != NULL )
- {
- RingBuffer_Write( &data->inFIFO, inputBuffer, numBytes );
- }
- if( outputBuffer != NULL )
- {
- int i;
- int numRead = RingBuffer_Read( &data->outFIFO, outputBuffer, numBytes );
- /* Zero out remainder of buffer if we run out of data. */
- for( i=numRead; i<numBytes; i++ )
- {
- ((char *)outputBuffer)[i] = 0;
- }
- }
-
- return 0;
-}
-
-/* Allocate buffer. */
-static PaError PABLIO_InitFIFO( RingBuffer *rbuf, long numFrames, long bytesPerFrame )
-{
- long numBytes = numFrames * bytesPerFrame;
- char *buffer = (char *) malloc( numBytes );
- if( buffer == NULL ) return paInsufficientMemory;
- memset( buffer, 0, numBytes );
- return (PaError) RingBuffer_Init( rbuf, numBytes, buffer );
-}
-
-/* Free buffer. */
-static PaError PABLIO_TermFIFO( RingBuffer *rbuf )
-{
- if( rbuf->buffer ) free( rbuf->buffer );
- rbuf->buffer = NULL;
- return paNoError;
-}
-
-/************************************************************
- * Write data to ring buffer.
- * Will not return until all the data has been written.
- */
-long WriteAudioStream( PABLIO_Stream *aStream, void *data, long numFrames )
-{
- long bytesWritten;
- char *p = (char *) data;
- long numBytes = aStream->bytesPerFrame * numFrames;
- while( numBytes > 0)
- {
- bytesWritten = RingBuffer_Write( &aStream->outFIFO, p, numBytes );
- numBytes -= bytesWritten;
- p += bytesWritten;
- if( numBytes > 0) NPa_Sleep(10); /* MSP */
- }
- return numFrames;
-}
-
-/************************************************************
- * Read data from ring buffer.
- * Will not return until all the data has been read.
- */
-long ReadAudioStream( PABLIO_Stream *aStream, void *data, long numFrames )
-{
- long bytesRead;
- char *p = (char *) data;
- long numBytes = aStream->bytesPerFrame * numFrames;
- while( numBytes > 0)
- {
- bytesRead = RingBuffer_Read( &aStream->inFIFO, p, numBytes );
- numBytes -= bytesRead;
- p += bytesRead;
- if( numBytes > 0) NPa_Sleep(10); /* MSP */
- }
- return numFrames;
-}
-
-/************************************************************
- * Return the number of frames that could be written to the stream without
- * having to wait.
- */
-long GetAudioStreamWriteable( PABLIO_Stream *aStream )
-{
- int bytesEmpty = RingBuffer_GetWriteAvailable( &aStream->outFIFO );
- return bytesEmpty / aStream->bytesPerFrame;
-}
-
-/************************************************************
- * Return the number of frames that are available to be read from the
- * stream without having to wait.
- */
-long GetAudioStreamReadable( PABLIO_Stream *aStream )
-{
- int bytesFull = RingBuffer_GetReadAvailable( &aStream->inFIFO );
- return bytesFull / aStream->bytesPerFrame;
-}
-
-/************************************************************/
-static unsigned long RoundUpToNextPowerOf2( unsigned long n )
-{
- long numBits = 0;
- if( ((n-1) & n) == 0) return n; /* Already Power of two. */
- while( n > 0 )
- {
- n= n>>1;
- numBits++;
- }
- return (1<<numBits);
-}
-
-/************************************************************
- * Opens a PortAudio stream with default characteristics.
- * Allocates PABLIO_Stream structure.
- *
- * flags parameter can be an ORed combination of:
- * PABLIO_READ, PABLIO_WRITE, or PABLIO_READ_WRITE
- */
-PaError OpenAudioStream( PABLIO_Stream **rwblPtr, double sampleRate,
- PaSampleFormat format, long flags, int nchannels,
- int framesperbuf, int nbuffers,
- int indeviceno, int outdeviceno) /* MSP */
-{
- long bytesPerSample;
- long doRead = 0;
- long doWrite = 0;
- PaError err;
- PABLIO_Stream *aStream;
- long minNumBuffers;
- long numFrames;
-
- /* fprintf(stderr,
- "open %lf fmt %d flags %d ch: %d fperbuf: %d nbuf: %d devs: %d %d\n",
- sampleRate, format, flags, nchannels,
- framesperbuf, nbuffers, indeviceno, outdeviceno); */
-
- if (indeviceno < 0) /* MSP... */
- {
- indeviceno = Pa_GetDefaultInputDeviceID();
- fprintf(stderr, "using default input device number: %d\n", indeviceno);
- }
- if (outdeviceno < 0)
- {
- outdeviceno = Pa_GetDefaultOutputDeviceID();
- fprintf(stderr, "using default output device number: %d\n", outdeviceno);
- }
- /* fprintf(stderr, "nchan %d, flags %d, bufs %d, framesperbuf %d\n",
- nchannels, flags, nbuffers, framesperbuf); */
- /* ...MSP */
-
- /* Allocate PABLIO_Stream structure for caller. */
- aStream = (PABLIO_Stream *) malloc( sizeof(PABLIO_Stream) );
- if( aStream == NULL ) return paInsufficientMemory;
- memset( aStream, 0, sizeof(PABLIO_Stream) );
-
- /* Determine size of a sample. */
- bytesPerSample = Pa_GetSampleSize( format );
- if( bytesPerSample < 0 )
- {
- err = (PaError) bytesPerSample;
- goto error;
- }
- aStream->samplesPerFrame = nchannels; /* MSP */
- aStream->bytesPerFrame = bytesPerSample * aStream->samplesPerFrame;
-
- /* Initialize PortAudio */
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
-/* Warning: numFrames must be larger than amount of data processed per
- interrupt inside PA to prevent glitches. */ /* MSP */
- minNumBuffers = Pa_GetMinNumBuffers(framesperbuf, sampleRate);
- if (minNumBuffers > nbuffers)
- fprintf(stderr,
- "warning: number of buffers %d less than recommended minimum %d\n",
- (int)nbuffers, (int)minNumBuffers);
- numFrames = nbuffers * framesperbuf;
- /* fprintf(stderr, "numFrames %d\n", numFrames); */
- /* Initialize Ring Buffers */
- doRead = ((flags & PABLIO_READ) != 0);
- doWrite = ((flags & PABLIO_WRITE) != 0);
- if(doRead)
- {
- err = PABLIO_InitFIFO( &aStream->inFIFO, numFrames, aStream->bytesPerFrame );
- if( err != paNoError ) goto error;
- }
- if(doWrite)
- {
- long numBytes;
- err = PABLIO_InitFIFO( &aStream->outFIFO, numFrames, aStream->bytesPerFrame );
- if( err != paNoError ) goto error;
- /* Make Write FIFO appear full initially. */
- numBytes = RingBuffer_GetWriteAvailable( &aStream->outFIFO );
- RingBuffer_AdvanceWriteIndex( &aStream->outFIFO, numBytes );
- }
-
- /* Open a PortAudio stream that we will use to communicate with the underlying
- * audio drivers. */
- err = Pa_OpenStream(
- &aStream->stream,
- (doRead ? indeviceno : paNoDevice), /* MSP */
- (doRead ? aStream->samplesPerFrame : 0 ),
- format,
- NULL,
- (doWrite ? outdeviceno : paNoDevice), /* MSP */
- (doWrite ? aStream->samplesPerFrame : 0 ),
- format,
- NULL,
- sampleRate,
- framesperbuf, /* MSP */
- nbuffers, /* MSP */
- paNoFlag, /* MSP -- portaudio will clip for us */
- blockingIOCallback,
- aStream );
- if( err != paNoError ) goto error;
-
- err = Pa_StartStream( aStream->stream );
- if( err != paNoError ) /* MSP */
- {
- fprintf(stderr, "Pa_StartStream failed; closing audio stream...\n");
- CloseAudioStream( aStream );
- goto error;
- }
-
- *rwblPtr = aStream;
- return paNoError;
-
-error:
- *rwblPtr = NULL;
- return err;
-}
-
-/************************************************************/
-PaError CloseAudioStream( PABLIO_Stream *aStream )
-{
- PaError err;
- int bytesEmpty;
- int byteSize = aStream->outFIFO.bufferSize;
-
- /* If we are writing data, make sure we play everything written. */
- if( byteSize > 0 )
- {
- bytesEmpty = RingBuffer_GetWriteAvailable( &aStream->outFIFO );
- while( bytesEmpty < byteSize )
- {
- NPa_Sleep( 10 ); /* MSP */
- bytesEmpty = RingBuffer_GetWriteAvailable( &aStream->outFIFO );
- }
- }
-
- err = Pa_StopStream( aStream->stream );
- if( err != paNoError ) goto error;
- err = Pa_CloseStream( aStream->stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
-
-error:
- PABLIO_TermFIFO( &aStream->inFIFO );
- PABLIO_TermFIFO( &aStream->outFIFO );
- free( aStream );
- return err;
-}
diff --git a/pd/portaudio_v18/pablio/pablio_pd.h b/pd/portaudio_v18/pablio/pablio_pd.h
deleted file mode 100644
index 7f01dc91..00000000
--- a/pd/portaudio_v18/pablio/pablio_pd.h
+++ /dev/null
@@ -1,110 +0,0 @@
-#ifndef _PABLIO_H
-#define _PABLIO_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-/*
- * $Id: pablio_pd.h,v 1.2 2004-02-22 16:21:33 ggeiger Exp $
- * PABLIO.h
- * Portable Audio Blocking read/write utility.
- *
- * Author: Phil Burk, http://www.softsynth.com/portaudio/
- *
- * Include file for PABLIO, the Portable Audio Blocking I/O Library.
- * PABLIO is built on top of PortAudio, the Portable Audio Library.
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * Any person wishing to distribute modifications to the Software is
- * requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include "portaudio.h"
-#include "ringbuffer.h"
-#include <string.h>
-
-typedef struct
-{
- RingBuffer inFIFO;
- RingBuffer outFIFO;
- PortAudioStream *stream;
- int bytesPerFrame;
- int samplesPerFrame;
-}
-PABLIO_Stream;
-
-/* Values for flags for OpenAudioStream(). */
-#define PABLIO_READ (1<<0)
-#define PABLIO_WRITE (1<<1)
-#define PABLIO_READ_WRITE (PABLIO_READ|PABLIO_WRITE)
-#define PABLIO_MONO (1<<2)
-#define PABLIO_STEREO (1<<3)
-
-/************************************************************
- * Write data to ring buffer.
- * Will not return until all the data has been written.
- */
-long WriteAudioStream( PABLIO_Stream *aStream, void *data, long numFrames );
-
-/************************************************************
- * Read data from ring buffer.
- * Will not return until all the data has been read.
- */
-long ReadAudioStream( PABLIO_Stream *aStream, void *data, long numFrames );
-
-/************************************************************
- * Return the number of frames that could be written to the stream without
- * having to wait.
- */
-long GetAudioStreamWriteable( PABLIO_Stream *aStream );
-
-/************************************************************
- * Return the number of frames that are available to be read from the
- * stream without having to wait.
- */
-long GetAudioStreamReadable( PABLIO_Stream *aStream );
-
-/************************************************************
- * Opens a PortAudio stream with default characteristics.
- * Allocates PABLIO_Stream structure.
- *
- * flags parameter can be an ORed combination of:
- * PABLIO_READ, PABLIO_WRITE, or PABLIO_READ_WRITE,
- */
-PaError OpenAudioStream( PABLIO_Stream **rwblPtr, double sampleRate,
- PaSampleFormat format, long flags, int nchannels,
- int framesperbuf, int nbuffers,
- int indeviceno, int outdeviceno); /* MSP */
-
-PaError CloseAudioStream( PABLIO_Stream *aStream );
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* _PABLIO_H */
diff --git a/pd/portaudio_v18/pablio/ringbuffer_pd.c b/pd/portaudio_v18/pablio/ringbuffer_pd.c
deleted file mode 100644
index a008ca3f..00000000
--- a/pd/portaudio_v18/pablio/ringbuffer_pd.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * $Id: ringbuffer_pd.c,v 1.2 2004-02-22 16:21:33 ggeiger Exp $
- * ringbuffer.c
- * Ring Buffer utility..
- *
- * Author: Phil Burk, http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * Any person wishing to distribute modifications to the Software is
- * requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-/*
- * modified 2002/07/13 by olaf.matthes@gmx.de to allow any number if channels
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include "ringbuffer.h"
-#include <string.h>
-
-/***************************************************************************
- * Initialize FIFO.
- */
-long RingBuffer_Init( RingBuffer *rbuf, long numBytes, void *dataPtr )
-{
- rbuf->bufferSize = numBytes;
- rbuf->buffer = (char *)dataPtr;
- RingBuffer_Flush( rbuf );
- return 0;
-}
-/***************************************************************************
-** Return number of bytes available for reading. */
-long RingBuffer_GetReadAvailable( RingBuffer *rbuf )
-{
- long ret = rbuf->writeIndex - rbuf->readIndex;
- if (ret < 0)
- ret += 2 * rbuf->bufferSize;
- if (ret < 0 || ret > rbuf->bufferSize)
- fprintf(stderr,
- "consistency check failed: RingBuffer_GetReadAvailable\n");
- return ( ret );
-}
-/***************************************************************************
-** Return number of bytes available for writing. */
-long RingBuffer_GetWriteAvailable( RingBuffer *rbuf )
-{
- return ( rbuf->bufferSize - RingBuffer_GetReadAvailable(rbuf));
-}
-
-/***************************************************************************
-** Clear buffer. Should only be called when buffer is NOT being read. */
-void RingBuffer_Flush( RingBuffer *rbuf )
-{
- rbuf->writeIndex = rbuf->readIndex = 0;
-}
-
-/***************************************************************************
-** Get address of region(s) to which we can write data.
-** If the region is contiguous, size2 will be zero.
-** If non-contiguous, size2 will be the size of second region.
-** Returns room available to be written or numBytes, whichever is smaller.
-*/
-long RingBuffer_GetWriteRegions( RingBuffer *rbuf, long numBytes,
- void **dataPtr1, long *sizePtr1,
- void **dataPtr2, long *sizePtr2 )
-{
- long index;
- long available = RingBuffer_GetWriteAvailable( rbuf );
- if( numBytes > available ) numBytes = available;
- /* Check to see if write is not contiguous. */
- index = rbuf->writeIndex;
- while (index >= rbuf->bufferSize)
- index -= rbuf->bufferSize;
- if( (index + numBytes) > rbuf->bufferSize )
- {
- /* Write data in two blocks that wrap the buffer. */
- long firstHalf = rbuf->bufferSize - index;
- *dataPtr1 = &rbuf->buffer[index];
- *sizePtr1 = firstHalf;
- *dataPtr2 = &rbuf->buffer[0];
- *sizePtr2 = numBytes - firstHalf;
- }
- else
- {
- *dataPtr1 = &rbuf->buffer[index];
- *sizePtr1 = numBytes;
- *dataPtr2 = NULL;
- *sizePtr2 = 0;
- }
- return numBytes;
-}
-
-
-/***************************************************************************
-*/
-long RingBuffer_AdvanceWriteIndex( RingBuffer *rbuf, long numBytes )
-{
- long ret = (rbuf->writeIndex + numBytes);
- if ( ret >= 2 * rbuf->bufferSize)
- ret -= 2 * rbuf->bufferSize; /* check for end of buffer */
- return rbuf->writeIndex = ret;
-}
-
-/***************************************************************************
-** Get address of region(s) from which we can read data.
-** If the region is contiguous, size2 will be zero.
-** If non-contiguous, size2 will be the size of second region.
-** Returns room available to be written or numBytes, whichever is smaller.
-*/
-long RingBuffer_GetReadRegions( RingBuffer *rbuf, long numBytes,
- void **dataPtr1, long *sizePtr1,
- void **dataPtr2, long *sizePtr2 )
-{
- long index;
- long available = RingBuffer_GetReadAvailable( rbuf );
- if( numBytes > available ) numBytes = available;
- /* Check to see if read is not contiguous. */
- index = rbuf->readIndex;
- while (index >= rbuf->bufferSize)
- index -= rbuf->bufferSize;
-
- if( (index + numBytes) > rbuf->bufferSize )
- {
- /* Write data in two blocks that wrap the buffer. */
- long firstHalf = rbuf->bufferSize - index;
- *dataPtr1 = &rbuf->buffer[index];
- *sizePtr1 = firstHalf;
- *dataPtr2 = &rbuf->buffer[0];
- *sizePtr2 = numBytes - firstHalf;
- }
- else
- {
- *dataPtr1 = &rbuf->buffer[index];
- *sizePtr1 = numBytes;
- *dataPtr2 = NULL;
- *sizePtr2 = 0;
- }
- return numBytes;
-}
-/***************************************************************************
-*/
-long RingBuffer_AdvanceReadIndex( RingBuffer *rbuf, long numBytes )
-{
- long ret = (rbuf->readIndex + numBytes);
- if( ret >= 2 * rbuf->bufferSize)
- ret -= 2 * rbuf->bufferSize;
- return rbuf->readIndex = ret;
-}
-
-/***************************************************************************
-** Return bytes written. */
-long RingBuffer_Write( RingBuffer *rbuf, void *data, long numBytes )
-{
- long size1, size2, numWritten;
- void *data1, *data2;
- numWritten = RingBuffer_GetWriteRegions( rbuf, numBytes, &data1, &size1, &data2, &size2 );
- if( size2 > 0 )
- {
-
- memcpy( data1, data, size1 );
- data = ((char *)data) + size1;
- memcpy( data2, data, size2 );
- }
- else
- {
- memcpy( data1, data, size1 );
- }
- RingBuffer_AdvanceWriteIndex( rbuf, numWritten );
- return numWritten;
-}
-
-/***************************************************************************
-** Return bytes read. */
-long RingBuffer_Read( RingBuffer *rbuf, void *data, long numBytes )
-{
- long size1, size2, numRead;
- void *data1, *data2;
- numRead = RingBuffer_GetReadRegions( rbuf, numBytes, &data1, &size1, &data2, &size2 );
- if( size2 > 0 )
- {
- memcpy( data, data1, size1 );
- data = ((char *)data) + size1;
- memcpy( data, data2, size2 );
- }
- else
- {
- memcpy( data, data1, size1 );
- }
- RingBuffer_AdvanceReadIndex( rbuf, numRead );
- return numRead;
-}
diff --git a/pd/portaudio_v18/pablio/test_w_saw_pd.c b/pd/portaudio_v18/pablio/test_w_saw_pd.c
deleted file mode 100644
index 73a4d9c4..00000000
--- a/pd/portaudio_v18/pablio/test_w_saw_pd.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * $Id: test_w_saw_pd.c,v 1.2 2004-02-22 16:21:33 ggeiger Exp $
- * test_w_saw.c
- * Generate stereo sawtooth waveforms.
- *
- * Author: Phil Burk, http://www.softsynth.com
- *
- * This program uses PABLIO, the Portable Audio Blocking I/O Library.
- * PABLIO is built on top of PortAudio, the Portable Audio Library.
- *
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * Any person wishing to distribute modifications to the Software is
- * requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include "pablio_pd.h"
-#include <string.h>
-
-#define SAMPLE_RATE (44100)
-#define NUM_SECONDS (6)
-#define SAMPLES_PER_FRAME (2)
-
-#define FREQUENCY (220.0f)
-#define PHASE_INCREMENT (2.0f * FREQUENCY / SAMPLE_RATE)
-#define FRAMES_PER_BLOCK (100)
-
-float samples[FRAMES_PER_BLOCK][SAMPLES_PER_FRAME];
-float phases[SAMPLES_PER_FRAME];
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- int i,j;
- PaError err;
- PABLIO_Stream *aOutStream;
-
- printf("Generate sawtooth waves using PABLIO.\n");
- fflush(stdout);
-
- /* Open simplified blocking I/O layer on top of PortAudio. */
- err = OpenAudioStream( &aOutStream, SAMPLE_RATE, paFloat32,
- PABLIO_WRITE, 2, 512, 8, -1, -1 );
- if( err != paNoError ) goto error;
-
- /* Initialize oscillator phases. */
- phases[0] = 0.0;
- phases[1] = 0.0;
-
- for( i=0; i<(NUM_SECONDS * SAMPLE_RATE); i += FRAMES_PER_BLOCK )
- {
- /* Generate sawtooth waveforms in a block for efficiency. */
- for( j=0; j<FRAMES_PER_BLOCK; j++ )
- {
- /* Generate a sawtooth wave by incrementing a variable. */
- phases[0] += PHASE_INCREMENT;
- /* The signal range is -1.0 to +1.0 so wrap around if we go over. */
- if( phases[0] > 1.0f ) phases[0] -= 2.0f;
- samples[j][0] = phases[0];
-
- /* On the second channel, generate a sawtooth wave a fifth higher. */
- phases[1] += PHASE_INCREMENT * (3.0f / 2.0f);
- if( phases[1] > 1.0f ) phases[1] -= 2.0f;
- samples[j][1] = phases[1];
- }
-
- /* Write samples to output. */
- WriteAudioStream( aOutStream, samples, FRAMES_PER_BLOCK );
- }
-
- CloseAudioStream( aOutStream );
-
- printf("Sawtooth sound test complete.\n" );
- fflush(stdout);
- return 0;
-
-error:
- fprintf( stderr, "An error occured while using PABLIO\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return -1;
-}
diff --git a/pd/portmidi_osx/MSP-README.txt b/pd/portmidi_osx/MSP-README.txt
deleted file mode 100644
index c48e8c8e..00000000
--- a/pd/portmidi_osx/MSP-README.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-This is from a PortMidi pre-release for OSX.
-
--MSP
diff --git a/pd/src/makefile.mingw b/pd/src/makefile.mingw
deleted file mode 100755
index 1d93cdcd..00000000
--- a/pd/src/makefile.mingw
+++ /dev/null
@@ -1,133 +0,0 @@
-VPATH = ../obj:./
-INSTDIR = ..
-OBJ_DIR = $(INSTDIR)/src
-BIN_DIR = $(INSTDIR)/bin
-
-PDEXEC = pd.exe
-GUINAME= pdtcl.dll
-DLLWRAP= dllwrap
-
-GFLAGS = -DINSTALL_PREFIX=\"$(INSTDIR)\"
-
-MORECFLAGS = -g
-
-PADIR = $(INSTDIR)/portaudio
-INCPA = -I$(PADIR) -I$(PADIR)/pa_common -I$(PADIR)/pablio -I../lib/asio
-INCLUDE =
-GINCLUDE = $(INCLUDE) -I../tcl/include
-
-LDFLAGS = -lpthreadGC -lwsock32 -lportaudio -lwinmm /lib/tcl85.lib /lib/tk85.lib
-LIB = -lm
-
-OPT_CFLAGS =
-WARN_CFLAGS = -Wall -W -Wstrict-prototypes \
- -Wno-unused-parameter -Wno-parentheses -Wno-switch
-ARCH_CFLAGS = -DPD -DPD_INTERNAL -DMSW -DUSEAPI_MMIO -DUSEAPI_PORTAUDIO \
-
-CFLAGS += $(ARCH_CFLAGS) $(WARN_CFLAGS) $(OPT_CFLAGS) $(MORECFLAGS)
-
-# the sources
-
-SYSSRC += s_audio_pa.c s_audio_mmio.c s_midi_mmio.c
-
-PASRC = $(PADIR)/pa_common/pa_lib.c $(PADIR)/pa_common/pa_trace.c \
- $(PADIR)/pablio/pablio_pd.c $(PADIR)/pablio/ringbuffer_pd.c
-
-GSRC = t_main.c t_tkcmd.c
-
-SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \
- g_scalar.c g_traversal.c g_guiconnect.c g_readwrite.c g_editor.c \
- g_all_guis.c g_bang.c g_hdial.c g_hslider.c g_mycanvas.c g_numbox.c \
- g_toggle.c g_vumeter.c m_pd.c m_class.c m_obj.c m_atom.c m_memory.c \
- m_binbuf.c m_conf.c m_glob.c m_sched.c s_main.c s_inter.c s_file.c \
- s_print.c s_loader.c s_path.c s_entry.c s_audio.c s_midi.c \
- d_ugen.c d_ctl.c d_arithmetic.c d_osc.c d_filter.c d_dac.c d_misc.c \
- d_math.c d_fft.c d_mayer_fft.c d_fftroutine.c d_array.c d_global.c \
- d_delay.c d_resample.c x_arithmetic.c x_connective.c x_interface.c \
- x_midi.c x_misc.c x_time.c x_acoustics.c x_net.c x_qlist.c x_gui.c \
- d_soundfile.c g_vslider.c g_vdial.c $(SYSSRC)
-
-SRSRC = u_pdsend.c u_pdreceive.c
-
-OBJ = $(SRC:.c=.o)
-GOBJ = $(GSRC:.c=.o)
-SROBJ = $(SRSRC:.c=.o)
-PAOBJ = $(PASRC:.c=.o)
-OBJC = $(OBJ) $(PAOBJ)
-
-#
-# ------------------ targets ------------------------------------
-#
-
-.PHONY: all
-
-all: $(OBJ_DIR)/$(GUINAME) $(OBJ_DIR)/$(PDDLL) $(OBJ_DIR)/$(PDEXEC) \
- $(OBJ_DIR)/pdsend.exe $(OBJ_DIR)/pdreceive.exe $(OBJ_DIR)/pd.tk
-
-$(OBJ) : %.o : %.c
- $(CC) $(CFLAGS) $(GFLAGS) $(INCLUDE) -c -o $(OBJ_DIR)/$*.o $*.c
-
-$(GOBJ) : %.o : %.c
- $(CC) $(CFLAGS) $(GFLAGS) $(GINCLUDE) -c -o $(OBJ_DIR)/$*.o $*.c
-
-$(SROBJ) : %.o : %.c
- $(CC) $(CFLAGS) $(GFLAGS) $(INCLUDE) -c -o $(OBJ_DIR)/$*.o $*.c
-
-$(PAOBJ) : %.o : %.c
- $(CC) $(CFLAGS) $(GFLAGS) $(INCPA) -c -o $(OBJ_DIR)/$*.o $*.c
-
-$(OBJ_DIR)/pdsend.exe: u_pdsend.o
- cd $(OBJ_DIR); $(CC) $(CFLAGS) $(STRIPFLAG) -o pdsend.exe u_pdsend.o $(LDFLAGS)
-
-$(OBJ_DIR)/pdreceive.exe: u_pdreceive.o
- cd $(OBJ_DIR); $(CC) $(CFLAGS) $(STRIPFLAG) -o pdreceive.exe u_pdreceive.o $(LDFLAGS)
-
-$(OBJ_DIR)/$(PDEXEC): s_entry.o
- cd $(OBJ_DIR); $(CC) -o $(PDEXEC) s_entry.o $(LIB) pd.a $(LDFLAGS)
-
-$(OBJ_DIR)/$(PDDLL): $(OBJC)
- cd $(OBJ_DIR); $(DLLWRAP) --export-all-symbols --output-def pd.def \
- --output-lib=pd.a --dllname=pd.dll $(OBJC) pdtcl.a $(LDFLAGS)
-
-$(OBJ_DIR)/$(GUINAME): t_tkcmd.o
- cd $(OBJ_DIR); $(DLLWRAP) --export-all-symbols --output-def pdtcl.def \
- --output-lib=pdtcl.a --dllname=$(GUINAME) t_tkcmd.o $(LDFLAGS)
-
-$(OBJ_DIR)/pd.tk: u_main.tk
- echo set pd_nt 1 > $(OBJ_DIR)/pd.tk
- grep -v "set pd_nt" < u_main.tk >> $(OBJ_DIR)/pd.tk
-
-install: all
- install -d $(INSTDIR)/bin
- install $(OBJ_DIR)/pd*.exe $(BIN_DIR)
- install $(OBJ_DIR)/pd*.dll $(BIN_DIR)
- install -m644 $(OBJ_DIR)/pd.tk $(BIN_DIR)/pd.tk
- install -m644 ../extra/*/*.pd $(INSTDIR)/doc/5.reference/
-
-clean:
- -rm -f $(OBJ_DIR)/*.o $(OBJ_DIR)/*.a $(OBJ_DIR)/*.def
- -rm -f $(OBJ_DIR)/pd*.exe $(OBJ_DIR)/pd*.dll
- -rm -f $(PADIR)/pablio/*.o $(PADIR)/pa_common/*.o
- -rm -f $(OBJ_DIR)/pd.tk
- -rm -f makefile.dependencies
- touch makefile.dependencies
- chmod 666 makefile.dependencies
-
-distclean: clean
- rm -rf config.cache config.log config.status makefile tags \
- autom4te-*.cache
- echo all: > makefile
- echo -e "\t./configure" >> makefile
- echo -e "\tmake" >> makefile
-
-tags: $(SRC) $(GSRC); ctags *.[ch]
-
-depend:
- $(CC) $(INCLUDE) $(CFLAGS) -M $(SRC) > makefile.dependencies
-
-uninstall:
- -rm $(INSTDIR)/bin/pd*.exe
- -rm $(INSTDIR)/bin/pd*.dll
- -rm $(INSTDIR)/bin/*.tk
-
-include makefile.dependencies
diff --git a/pd/src/makefile.nt.pa19 b/pd/src/makefile.nt.pa19
deleted file mode 100644
index 9105d734..00000000
--- a/pd/src/makefile.nt.pa19
+++ /dev/null
@@ -1,185 +0,0 @@
-# Makefile for PD on MSW
-
-all: pd gui ..\bin\pd.tk ..\bin\pdsend.exe ..\bin\pdreceive.exe
-
-VC = "C:\Program Files\Microsoft Visual Studio\VC98"
-#VC="\Program Files\DevStudio\Vc"
-INCLUDE = -I.\ -I..\Tcl\include -I$(VC)\include
-
-LDIR = $(VC)\lib
-
-LIB = /NODEFAULTLIB:libc /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel \
- /NODEFAULTLIB:uuid \
- $(LDIR)\libc.lib $(LDIR)\oldnames.lib $(LDIR)\kernel32.lib \
- $(LDIR)\wsock32.lib $(LDIR)\winmm.lib ..\bin\pthreadVC.lib
-
-GLIB = $(LIB) ..\lib\tcl83.lib ..\lib\tk83.lib
-CFLAGS = /nologo /W3 /DMSW /DNT /DPD /DPD_INTERNAL /DWIN32 /DWINDOWS /Ox \
- -DPA_LITTLE_ENDIAN -DUSEAPI_MMIO -DUSEAPI_PORTAUDIO
-LFLAGS = /nologo
-
-SYSSRC = s_audio_pa.c s_audio_mmio.c s_midi_pm.c
-
-SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \
- g_scalar.c g_traversal.c g_guiconnect.c g_readwrite.c g_editor.c \
- g_all_guis.c g_bang.c g_hdial.c g_hslider.c g_mycanvas.c g_numbox.c \
- g_toggle.c g_vdial.c g_vslider.c g_vumeter.c \
- m_pd.c m_class.c m_obj.c m_atom.c m_memory.c m_binbuf.c \
- m_conf.c m_glob.c m_sched.c \
- s_main.c s_inter.c s_file.c s_print.c \
- s_loader.c s_path.c s_entry.c s_audio.c s_midi.c \
- d_ugen.c d_ctl.c d_arithmetic.c d_osc.c d_filter.c d_dac.c d_misc.c \
- d_math.c d_fft.c d_mayer_fft.c d_fftroutine.c d_array.c d_global.c \
- d_delay.c d_resample.c \
- x_arithmetic.c x_connective.c x_interface.c x_midi.c x_misc.c \
- x_time.c x_acoustics.c x_net.c x_qlist.c x_gui.c d_soundfile.c \
- $(SYSSRC)
-
-PADIR = ..\portaudio
-INCPA = -I$(PADIR) -I$(PADIR)\pa_common -I$(PADIR)\pablio -I..\lib\asio
-SRCPA = \
- $(PADIR)/pa_common/pa_allocation.c \
- $(PADIR)/pa_common/pa_converters.c \
- $(PADIR)/pa_common/pa_cpuload.c \
- $(PADIR)/pa_common/pa_dither.c \
- $(PADIR)/pa_common/pa_front.c \
- $(PADIR)/pa_common/pa_process.c \
- $(PADIR)/pa_common/pa_skeleton.c \
- $(PADIR)/pa_common/pa_stream.c \
- $(PADIR)/pa_common/pa_trace.c \
- $(PADIR)/pablio/pablio_pd.c \
- $(PADIR)/pablio/ringbuffer_pd.c \
- $(PADIR)/pa_win/pa_win_hostapis.c \
- $(PADIR)/pa_win/pa_win_util.c \
- $(PADIR)/pa_win/pa_x86_plain_converters.c \
- $(PADIR)/pa_win_wmme/pa_win_wmme.c
-
-# $(PADIR)/pa_win_ds/dsound_wrapper.c \
-# $(PADIR)/pa_win_ds/pa_dsound.c \
-# $(PADIR)/pa_win_ds/pa_win_ds.c \
-
-PAOBJ = \
- pa_allocation.obj pa_converters.obj pa_cpuload.obj pa_dither.obj pa_front.obj \
- pa_process.obj pa_skeleton.obj pa_stream.obj pa_trace.obj pablio_pd.obj \
- ringbuffer_pd.obj pa_win_hostapis.obj pa_win_util.obj \
- pa_x86_plain_converters.obj \
- pa_win_wmme.obj pa_asio.obj \
-
-# dsound_wrapper.obj pa_dsound.obj pa_win_ds.obj
-
-
-SRCASIO = $(PADIR)/pa_asio/pa_asio.cpp
-ASIOLIB = $(LDIR)\user32.lib $(LDIR)\gdi32.lib $(LDIR)\winspool.lib \
- $(LDIR)\comdlg32.lib \
-$(LDIR)\advapi32.lib $(LDIR)\shell32.lib $(LDIR)\ole32.lib $(LDIR)\oleaut32.lib $(LDIR)\uuid.lib \
-$(LDIR)\odbc32.lib $(LDIR)\odbccp32.lib ..\lib\asio\asiolib.lib
-
-PMDIR = ..\portmidi
-INCPM = -I$(PMDIR)\pm_common -I$(PMDIR)\pm_win -I$(PMDIR)\porttime
-SRCPM = \
- $(PMDIR)/pm_common/portmidi.c \
- $(PMDIR)/pm_common/pmutil.c \
- $(PMDIR)/pm_win/pmwin.c \
- $(PMDIR)/pm_win/pmwinmm.c \
- $(PMDIR)/porttime/porttime.c \
- $(PMDIR)/porttime/ptwinmm.c \
-
-PMOBJ = portmidi.obj pmutil.obj pmwin.obj pmwinmm.obj porttime.obj ptwinmm.obj
-
-OBJC = $(SRC:.c=.obj) $(PAOBJ) $(PMOBJ)
-
-GSRC = t_main.c t_tkcmd.c
-
-GOBJ = $(GSRC:.c=.obj)
-.PHONY: pd gui
-
-ALLCF = $(CFLAGS) $(INCLUDE) $(INCASIO) $(INCPA) $(INCPM) /D_WINDOWS /DPA_NO_DS
-
-.c.obj:
- cl /c $(ALLCF) /Tc$*.c
-
-pd: ..\bin\pd.exe
-
-gui: ..\bin\pdtcl.dll
-
-..\bin\pd.exe: s_entry.obj ..\bin\pd.lib
- link $(LFLAGS) /out:..\bin\pd.exe /INCREMENTAL:NO s_entry.obj \
- ..\bin\pd.lib $(LIB) $(ASIOLIB)
-
-..\bin\pd.dll ..\bin\pd.lib: $(OBJC) $(OBJASIO)
- link $(LFLAGS) /dll /export:sys_main /out:..\bin\pd.dll $(OBJC) \
- $(OBJASIO) $(LIB) $(ASIOLIB)
-
-..\bin\pdtcl.dll: t_tkcmd.obj
- link $(LFLAGS) /dll /export:Pdtcl_Init /out:..\bin\pdtcl.dll \
- t_tkcmd.obj $(GLIB)
-
-..\bin\pd.tk: u_main.tk; copy u_main.tk ..\bin\pd.tk
-
-..\bin\pdsend.exe: u_pdsend.obj
- link $(LFLAGS) /out:..\bin\pdsend.exe /INCREMENTAL:NO u_pdsend.obj \
- $(LIB)
-
-..\bin\pdreceive.exe: u_pdreceive.obj
- link $(LFLAGS) /out:..\bin\pdreceive.exe /INCREMENTAL:NO u_pdreceive.obj \
- $(LIB)
-
-# explicit rules to compile portaudio and portmidi sources:
-pa_allocation.obj: $(PADIR)\pa_common\pa_allocation.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_allocation.c
-pa_converters.obj: $(PADIR)\pa_common\pa_converters.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_converters.c
-pa_cpuload.obj: $(PADIR)\pa_common\pa_cpuload.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_cpuload.c
-pa_dither.obj: $(PADIR)\pa_common\pa_dither.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_dither.c
-pa_front.obj: $(PADIR)\pa_common\pa_front.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_front.c
-pa_process.obj: $(PADIR)\pa_common\pa_process.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_process.c
-pa_skeleton.obj: $(PADIR)\pa_common\pa_skeleton.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_skeleton.c
-pa_stream.obj: $(PADIR)\pa_common\pa_stream.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_stream.c
-pa_trace.obj: $(PADIR)\pa_common\pa_trace.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_trace.c
-pablio_pd.obj: $(PADIR)\pablio\pablio_pd.c
- cl /c $(ALLCF) $(PADIR)\pablio\pablio_pd.c
-ringbuffer_pd.obj: $(PADIR)\pablio\ringbuffer_pd.c
- cl /c $(ALLCF) $(PADIR)\pablio\ringbuffer_pd.c
-pa_win_hostapis.obj: $(PADIR)\pa_win\pa_win_hostapis.c
- cl /c $(ALLCF) $(PADIR)\pa_win\pa_win_hostapis.c
-pa_win_util.obj: $(PADIR)\pa_win\pa_win_util.c
- cl /c $(ALLCF) $(PADIR)\pa_win\pa_win_util.c
-pa_x86_plain_converters.obj: $(PADIR)\pa_win\pa_x86_plain_converters.c
- cl /c $(ALLCF) $(PADIR)\pa_win\pa_x86_plain_converters.c
-dsound_wrapper.obj: $(PADIR)\pa_win_ds\dsound_wrapper.c
- cl /c $(ALLCF) $(PADIR)\pa_win_ds\dsound_wrapper.c
-pa_dsound.obj: $(PADIR)\pa_win_ds\pa_dsound.c
- cl /c $(ALLCF) $(PADIR)\pa_win_ds\pa_dsound.c
-pa_win_ds.obj: $(PADIR)\pa_win_ds\pa_win_ds.c
- cl /c $(ALLCF) $(PADIR)\pa_win_ds\pa_win_ds.c
-pa_win_wmme.obj: $(PADIR)\pa_win_wmme\pa_win_wmme.c
- cl /c $(ALLCF) $(PADIR)\pa_win_wmme\pa_win_wmme.c
-
-pa_asio.obj: $(PADIR)\pa_asio\pa_asio.cpp
- cl /c $(ALLCF) $(PADIR)\pa_asio\pa_asio.cpp
-
-portmidi.obj: $(PMDIR)\pm_common\portmidi.c
- cl /c $(ALLCF) $(PMDIR)\pm_common\portmidi.c
-pmutil.obj: $(PMDIR)\pm_common\pmutil.c
- cl /c $(ALLCF) $(PMDIR)\pm_common\pmutil.c
-pmwin.obj: $(PMDIR)\pm_win\pmwin.c
- cl /c $(ALLCF) $(PMDIR)\pm_win\pmwin.c
-pmwinmm.obj: $(PMDIR)\pm_win\pmwinmm.c
- cl /c $(ALLCF) $(PMDIR)\pm_win\pmwinmm.c
-porttime.obj: $(PMDIR)\porttime\porttime.c
- cl /c $(ALLCF) $(PMDIR)\porttime\porttime.c
-ptwinmm.obj: $(PMDIR)\porttime\ptwinmm.c
- cl /c $(ALLCF) $(PMDIR)\porttime\ptwinmm.c
-
-# the following should also clean up "bin" but it doesn't because "bin" holds
-# precious stuff from elsewhere.
-clean:
- del *.obj
-
diff --git a/pd/src/s_audio_alsa.c.old b/pd/src/s_audio_alsa.c.old
deleted file mode 100644
index 99ca3403..00000000
--- a/pd/src/s_audio_alsa.c.old
+++ /dev/null
@@ -1,946 +0,0 @@
-/* Copyright (c) 1997-2003 Guenter Geiger, Miller Puckette, Larry Troxler,
-* Winfried Ritsch, Karl MacMillan, and others.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
-
-/* this file inputs and outputs audio using the ALSA API available on linux. */
-
-#include <alsa/asoundlib.h>
-
-#include "m_pd.h"
-#include "s_stuff.h"
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <sched.h>
-#include <sys/mman.h>
-
-typedef int16_t t_alsa_sample16;
-typedef int32_t t_alsa_sample32;
-#define ALSA_SAMPLEWIDTH_16 sizeof(t_alsa_sample16)
-#define ALSA_SAMPLEWIDTH_32 sizeof(t_alsa_sample32)
-#define ALSA_XFERSIZE16 (signed int)(sizeof(t_alsa_sample16) * DEFDACBLKSIZE)
-#define ALSA_XFERSIZE32 (signed int)(sizeof(t_alsa_sample32) * DEFDACBLKSIZE)
-#define ALSA_MAXDEV 1
-#define ALSA_JITTER 1024
-#define ALSA_EXTRABUFFER 2048
-#define ALSA_DEFFRAGSIZE 64
-#define ALSA_DEFNFRAG 12
-
-#ifndef INT32_MAX
-#define INT32_MAX 0x7fffffff
-#endif
-
-#if (SND_LIB_MAJOR < 1)
-#define ALSAAPI9
-#endif
-
-typedef struct _alsa_dev
-{
- snd_pcm_t *inhandle;
- snd_pcm_t *outhandle;
- int innoninterleave; /* true if we're set for noninterleaved read */
- int outnoninterleave; /* same for write */
-} t_alsa_dev;
-
-t_alsa_dev alsa_device;
-static void *alsa_snd_buf = 0;
-static void **alsa_buf_ptrs;
-static int alsa_samplewidth;
-static snd_pcm_status_t* in_status;
-static snd_pcm_status_t* out_status;
-
-static int alsa_mode;
-static int alsa_buf_samps; /* believed actual ALSA bufsize in sample frames */
-static int alsa_inchannels;
-static int alsa_outchannels;
-
-/* Defines */
-#define DEBUG(x) x
-#define DEBUG2(x) {x;}
-
-static void alsa_checkiosync( void);
-static void alsa_numbertoname(int devno, char *devname, int nchar);
-
- /* don't assume we can turn all 31 bits when doing float-to-fix;
- otherwise some audio drivers (e.g. Midiman/ALSA) wrap around. */
-#define FMAX 0x7ffff000
-#define CLIP32(x) (((x)>FMAX)?FMAX:((x) < -FMAX)?-FMAX:(x))
-
-/* support for ALSA pcmv2 api by Karl MacMillan<karlmac@peabody.jhu.edu> */
-
-static void check_error(int err, const char *why)
-{
- if (err < 0)
- fprintf(stderr, "%s: %s\n", why, snd_strerror(err));
-}
-
-/* was: alsa_open_audio(int wantinchans, int wantoutchans, int srate) */
-
-int alsa_open_audio(int naudioindev, int *audioindev, int nchindev,
- int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
- int *choutdev, int rate)
-{
- int err, inchans = 0, outchans = 0, subunitdir;
- char devname[512];
- snd_pcm_hw_params_t* hw_params;
- snd_pcm_sw_params_t* sw_params;
- snd_output_t* out;
- int frag_size = (sys_blocksize ? sys_blocksize : ALSA_DEFFRAGSIZE);
- int nfrags, i;
- short* tmp_buf;
- unsigned int tmp_uint;
- snd_pcm_uframes_t tmp_snd_pcm_uframes;
- int wantinchans, wantoutchans, devno;
-
- if (naudioindev >= 2 || naudiooutdev >= 2)
- post("alsa: only one input and output device allowed (extras ignored");
- if (naudioindev >= 1 && naudiooutdev >= 1 &&
- audioindev[0] != audiooutdev[0])
- post("alsa: changing output device to agree with input device");
- if (nchindev)
- wantinchans = chindev[0];
- else wantinchans = (naudioindev ? 2 : 0);
- if (nchoutdev)
- wantoutchans = choutdev[0];
- else wantoutchans = (naudiooutdev ? 2 : 0);
- devno = (naudioindev > 0 ? audioindev[0] :
- (naudiooutdev > 0 ? audiooutdev[0] : 0));
-
- alsa_numbertoname(devno, devname, 512);
-
- if (sys_verbose)
- post("device name %s; channels in %d, out %d", devname, wantinchans,
- wantoutchans);
-
- nfrags = sys_schedadvance * (float)rate / (1e6 * frag_size);
- /* save our belief as to ALSA's buffer size for later */
- alsa_buf_samps = nfrags * frag_size;
-
- if (sys_verbose)
- post("audio buffer set to %d", (int)(0.001 * sys_schedadvance));
-
- alsa_device.innoninterleave = alsa_device.outnoninterleave = 0;
- if (wantinchans)
- {
- err = snd_pcm_open(&alsa_device.inhandle, devname,
- SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK);
-
- check_error(err, "snd_pcm_open (input)");
- if (err < 0)
- inchans = 0;
- else
- {
- inchans = wantinchans;
- snd_pcm_nonblock(alsa_device.inhandle, 1);
- }
- }
- if (wantoutchans)
- {
- err = snd_pcm_open(&alsa_device.outhandle, devname,
- SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
-
- check_error(err, "snd_pcm_open (output)");
- if (err < 0)
- outchans = 0;
- else
- {
- outchans = wantoutchans;
- snd_pcm_nonblock(alsa_device.outhandle, 1);
- }
- }
- if (inchans)
- {
- if (sys_verbose)
- post("opening sound input...");
- err = snd_pcm_hw_params_malloc(&hw_params);
- check_error(err, "snd_pcm_hw_params_malloc (input)");
-
- // get the default params
- err = snd_pcm_hw_params_any(alsa_device.inhandle, hw_params);
- check_error(err, "snd_pcm_hw_params_any (input)");
-
- /* try to set interleaved access */
- err = snd_pcm_hw_params_set_access(alsa_device.inhandle,
- hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
- if (err < 0)
- {
- /* OK, so try non-interleaved */
- err = snd_pcm_hw_params_set_access(alsa_device.inhandle,
- hw_params, SND_PCM_ACCESS_RW_NONINTERLEAVED);
- if (err >= 0)
- {
- post("using non-interleaved audio input");
- alsa_device.innoninterleave = 1;
- }
- }
- check_error(err, "snd_pcm_hw_params_set_access (input)");
- // Try to set 32 bit format first
- err = snd_pcm_hw_params_set_format(alsa_device.inhandle, hw_params,
- SND_PCM_FORMAT_S32);
- if (err < 0)
- {
- /* fprintf(stderr,
- "PD-ALSA: 32 bit format not available - using 16\n"); */
- err = snd_pcm_hw_params_set_format(alsa_device.inhandle, hw_params,
- SND_PCM_FORMAT_S16);
- check_error(err, "snd_pcm_hw_params_set_format (input)");
- alsa_samplewidth = 2;
- }
- else
- {
- alsa_samplewidth = 4;
- }
- post("Sample width set to %d bytes", alsa_samplewidth);
- // set the subformat
- err = snd_pcm_hw_params_set_subformat(alsa_device.inhandle, hw_params,
- SND_PCM_SUBFORMAT_STD);
- check_error(err, "snd_pcm_hw_params_set_subformat (input)");
- // set the number of channels
- tmp_uint = inchans;
- err = snd_pcm_hw_params_set_channels_min(alsa_device.inhandle,
- hw_params, &tmp_uint);
- check_error(err, "snd_pcm_hw_params_set_channels (input)");
- if (tmp_uint != (unsigned)inchans)
- post("ALSA: set input channels to %d", tmp_uint);
- inchans = tmp_uint;
- // set the sampling rate
- err = snd_pcm_hw_params_set_rate_min(alsa_device.inhandle, hw_params,
- &rate, 0);
- check_error(err, "snd_pcm_hw_params_set_rate_min (input)");
-#if 0
- err = snd_pcm_hw_params_get_rate(hw_params, &subunitdir);
- post("input sample rate %d", err);
-#endif
- // set the period - ie frag size
- // post("fragsize a %d", frag_size);
-
- /* LATER try this to get a recommended period size...
- right now, it trips an assertion failure in ALSA lib */
-#if 0
- post("input period was %d, min %d, max %d\n",
- snd_pcm_hw_params_get_period_size(hw_params, 0),
- snd_pcm_hw_params_get_period_size_min(hw_params, 0),
- snd_pcm_hw_params_get_period_size_max(hw_params, 0));
-#endif
-#ifdef ALSAAPI9
- err = snd_pcm_hw_params_set_period_size_near(alsa_device.inhandle,
- hw_params,
- (snd_pcm_uframes_t)
- frag_size, 0);
-#else
- tmp_snd_pcm_uframes = frag_size;
- err = snd_pcm_hw_params_set_period_size_near(alsa_device.inhandle,
- hw_params, &tmp_snd_pcm_uframes, 0);
-#endif
- check_error(err, "snd_pcm_hw_params_set_period_size_near (input)");
- // post("fragsize b %d", frag_size);
- // set the number of periods - ie numfrags
- // post("nfrags a %d", nfrags);
-#ifdef ALSAAPI9
- err = snd_pcm_hw_params_set_periods_near(alsa_device.inhandle,
- hw_params, nfrags, 0);
-#else
- tmp_uint = nfrags;
- err = snd_pcm_hw_params_set_periods_near(alsa_device.inhandle,
- hw_params, &tmp_uint, 0);
-#endif
- check_error(err, "snd_pcm_hw_params_set_periods_near (input)");
- // set the buffer size
-#ifdef ALSAAPI9
- err = snd_pcm_hw_params_set_buffer_size_near(alsa_device.inhandle,
- hw_params, nfrags * frag_size);
-#else
- tmp_snd_pcm_uframes = nfrags * frag_size;
- err = snd_pcm_hw_params_set_buffer_size_near(alsa_device.inhandle,
- hw_params, &tmp_snd_pcm_uframes);
-#endif
- check_error(err, "snd_pcm_hw_params_set_buffer_size_near (input)");
-
- err = snd_pcm_hw_params(alsa_device.inhandle, hw_params);
- check_error(err, "snd_pcm_hw_params (input)");
-
- snd_pcm_hw_params_free(hw_params);
-
- err = snd_pcm_sw_params_malloc(&sw_params);
- check_error(err, "snd_pcm_sw_params_malloc (input)");
- err = snd_pcm_sw_params_current(alsa_device.inhandle, sw_params);
- check_error(err, "snd_pcm_sw_params_current (input)");
- err = snd_pcm_sw_params_set_start_threshold(alsa_device.inhandle,
- sw_params, nfrags * frag_size);
- check_error(err, "snd_pcm_sw_params_set_start_threshold (input)");
- err = snd_pcm_sw_params_set_stop_threshold(alsa_device.inhandle,
- sw_params, 0x7fffffff);
- check_error(err, "snd_pcm_sw_params_set_stop_threshold (input)");
- err = snd_pcm_sw_params_set_avail_min(alsa_device.inhandle, sw_params,
- frag_size);
- check_error(err, "snd_pcm_sw_params_set_avail_min (input)");
- err = snd_pcm_sw_params(alsa_device.inhandle, sw_params);
- check_error(err, "snd_pcm_sw_params (input)");
-
- snd_pcm_sw_params_free(sw_params);
-
- snd_output_stdio_attach(&out, stderr, 0);
-#if 0
- if (sys_verbose)
- {
- snd_pcm_dump_hw_setup(alsa_device.inhandle, out);
- snd_pcm_dump_sw_setup(alsa_device.inhandle, out);
- }
-#endif
- }
-
- if (outchans)
- {
- int foo;
- if (sys_verbose)
- post("opening sound output...");
- err = snd_pcm_hw_params_malloc(&hw_params);
- check_error(err, "snd_pcm_sw_params (output)");
-
- // get the default params
- err = snd_pcm_hw_params_any(alsa_device.outhandle, hw_params);
- check_error(err, "snd_pcm_hw_params_any (output)");
- // set interleaved access - FIXME deal with other access types
- err = snd_pcm_hw_params_set_access(alsa_device.outhandle, hw_params,
- SND_PCM_ACCESS_RW_INTERLEAVED);
- check_error(err, "snd_pcm_hw_params_set_access (output)");
-
- /* try to set interleaved access */
- err = snd_pcm_hw_params_set_access(alsa_device.outhandle,
- hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
- if (err < 0)
- {
- /* OK, so try non-interleaved */
- err = snd_pcm_hw_params_set_access(alsa_device.outhandle,
- hw_params, SND_PCM_ACCESS_RW_NONINTERLEAVED);
- if (err >= 0)
- {
- post("using non-interleaved audio");
- alsa_device.outnoninterleave = 1;
- }
- }
- check_error(err, "snd_pcm_hw_params_set_access (output)");
-
-
- // Try to set 32 bit format first
- err = snd_pcm_hw_params_set_format(alsa_device.outhandle, hw_params,
- SND_PCM_FORMAT_S32);
- if (err < 0)
- {
- err = snd_pcm_hw_params_set_format(alsa_device.outhandle,
- hw_params,SND_PCM_FORMAT_S16);
- check_error(err, "snd_pcm_hw_params_set_format (output)");
- /* fprintf(stderr,
- "PD-ALSA: 32 bit format not available - using 16\n"); */
- alsa_samplewidth = 2;
- }
- else
- {
- alsa_samplewidth = 4;
- }
- // set the subformat
- err = snd_pcm_hw_params_set_subformat(alsa_device.outhandle, hw_params,
- SND_PCM_SUBFORMAT_STD);
- check_error(err, "snd_pcm_hw_params_set_subformat (output)");
- // set the number of channels
- tmp_uint = outchans;
- err = snd_pcm_hw_params_set_channels_min(alsa_device.outhandle,
- hw_params, &tmp_uint);
- check_error(err, "snd_pcm_hw_params_set_channels (output)");
- if (tmp_uint != (unsigned)outchans)
- post("alsa: set output channels to %d", tmp_uint);
- outchans = tmp_uint;
- // set the sampling rate
- err = snd_pcm_hw_params_set_rate_min(alsa_device.outhandle, hw_params,
- &rate, 0);
- check_error(err, "snd_pcm_hw_params_set_rate_min (output)");
-#if 0
- err = snd_pcm_hw_params_get_rate(hw_params, &subunitdir);
- post("output sample rate %d", err);
-#endif
- // set the period - ie frag size
-#if 0
- post("output period was %d, min %d, max %d\n",
- snd_pcm_hw_params_get_period_size(hw_params, 0),
- snd_pcm_hw_params_get_period_size_min(hw_params, 0),
- snd_pcm_hw_params_get_period_size_max(hw_params, 0));
-#endif
- // post("fragsize c %d", frag_size);
-#ifdef ALSAAPI9
- err = snd_pcm_hw_params_set_period_size_near(alsa_device.outhandle,
- hw_params,
- (snd_pcm_uframes_t)
- frag_size, 0);
-#else
- tmp_snd_pcm_uframes = frag_size;
- err = snd_pcm_hw_params_set_period_size_near(alsa_device.outhandle,
- hw_params, &tmp_snd_pcm_uframes, 0);
-#endif
- // post("fragsize d %d", frag_size);
- check_error(err, "snd_pcm_hw_params_set_period_size_near (output)");
- // set the number of periods - ie numfrags
-#ifdef ALSAAPI9
- err = snd_pcm_hw_params_set_periods_near(alsa_device.outhandle,
- hw_params, nfrags, 0);
-#else
- tmp_uint = nfrags;
- err = snd_pcm_hw_params_set_periods_near(alsa_device.outhandle,
- hw_params, &tmp_uint, 0);
-#endif
- check_error(err, "snd_pcm_hw_params_set_periods_near (output)");
- // set the buffer size
-#ifdef ALSAAPI9
- err = snd_pcm_hw_params_set_buffer_size_near(alsa_device.outhandle,
- hw_params, nfrags * frag_size);
-#else
- tmp_snd_pcm_uframes = nfrags * frag_size;
- err = snd_pcm_hw_params_set_buffer_size_near(alsa_device.outhandle,
- hw_params, &tmp_snd_pcm_uframes);
-#endif
- check_error(err, "snd_pcm_hw_params_set_buffer_size_near (output)");
-
- err = snd_pcm_hw_params(alsa_device.outhandle, hw_params);
- check_error(err, "snd_pcm_hw_params (output)");
-
- snd_pcm_hw_params_free(hw_params);
-
- err = snd_pcm_sw_params_malloc(&sw_params);
- check_error(err, "snd_pcm_sw_params_malloc (output)");
- err = snd_pcm_sw_params_current(alsa_device.outhandle, sw_params);
- check_error(err, "snd_pcm_sw_params_current (output)");
- err = snd_pcm_sw_params_set_start_threshold(alsa_device.outhandle,
- sw_params, nfrags * frag_size);
- check_error(err, "snd_pcm_sw_params_set_start_threshold (output)");
- err = snd_pcm_sw_params_set_stop_threshold(alsa_device.outhandle,
- sw_params, 0x7fffffff);
- check_error(err, "snd_pcm_sw_params_set_stop_threshold (output)");
- err = snd_pcm_sw_params_set_avail_min(alsa_device.outhandle, sw_params,
- frag_size);
- check_error(err, "snd_pcm_sw_params_set_avail_min (output)");
- err = snd_pcm_sw_params(alsa_device.outhandle, sw_params);
- check_error(err, "snd_pcm_sw_params (output)");
- snd_pcm_sw_params_free(sw_params);
-
- snd_output_stdio_attach(&out, stderr, 0);
-#if 0
- if (sys_verbose)
- {
- snd_pcm_dump_hw_setup(alsa_device.outhandle, out);
- snd_pcm_dump_sw_setup(alsa_device.outhandle, out);
- }
-#endif
- }
-
- if (inchans)
- snd_pcm_prepare(alsa_device.inhandle);
- if (outchans)
- snd_pcm_prepare(alsa_device.outhandle);
-
- // if duplex we can link the channels so they start together
- if (inchans && outchans)
- snd_pcm_link(alsa_device.inhandle, alsa_device.outhandle);
-
- // set up the status variables
- err = snd_pcm_status_malloc(&in_status);
- check_error(err, "snd_pcm_status_malloc");
- err = snd_pcm_status_malloc(&out_status);
- check_error(err, "snd_pcm_status_malloc");
-
- // set up the buffer
- if (alsa_snd_buf)
- free(alsa_snd_buf);
- alsa_snd_buf = (void *)malloc(
- sizeof(char) * alsa_samplewidth * DEFDACBLKSIZE *
- (outchans > inchans ? outchans : inchans));
- memset(alsa_snd_buf, 0, sizeof(char) * alsa_samplewidth * DEFDACBLKSIZE *
- (outchans > inchans ? outchans : inchans));
- /* make an array of pointers too in case we need them */
- if (alsa_buf_ptrs)
- free(alsa_buf_ptrs);
- alsa_buf_ptrs = (void **)malloc(
- sizeof(void *) * (outchans > inchans ? outchans : inchans));
- for (i = 0; i < (outchans > inchans ? outchans : inchans); i++)
- alsa_buf_ptrs[i] = (t_alsa_sample32 *)alsa_snd_buf + i * DEFDACBLKSIZE;
-
- // fill the buffer with silence
- if (outchans)
- {
- i = (frag_size * nfrags)/DEFDACBLKSIZE + 1;
- while (i--)
- {
- if (alsa_device.outnoninterleave)
- snd_pcm_writen(alsa_device.outhandle, alsa_buf_ptrs,
- DEFDACBLKSIZE);
- else snd_pcm_writei(alsa_device.outhandle, alsa_snd_buf,
- DEFDACBLKSIZE);
- }
- /* confused about this: */
- /* if ((err = snd_pcm_start(alsa_device.outhandle) < 0))
- check_error(err, "output start failed\n"); */
- }
- else if (inchans)
- {
- if (snd_pcm_start(alsa_device.inhandle) < 0)
- check_error(err, "input start failed\n");
- }
- alsa_outchannels = outchans;
- alsa_inchannels = inchans;
-
- return (!(inchans || outchans));
-}
-
-void alsa_close_audio(void)
-{
- int err;
- if (alsa_inchannels)
- {
- err = snd_pcm_close(alsa_device.inhandle);
- check_error(err, "snd_pcm_close (input)");
- }
- if (alsa_outchannels)
- {
- err = snd_pcm_close(alsa_device.outhandle);
- check_error(err, "snd_pcm_close (output)");
- }
-}
-
-// #define DEBUG_ALSA_XFER
-
-int alsa_send_dacs(void)
-{
- static int16_t *sp;
- static int xferno = 0;
- static int callno = 0;
- static double timenow;
- double timelast;
- t_sample *fp, *fp1, *fp2;
- int i, j, k, err, devno = 0;
- int inputcount = 0, outputcount = 0, inputlate = 0, outputlate = 0;
- int result;
- int inchannels = (sys_inchannels > alsa_inchannels ?
- alsa_inchannels : sys_inchannels);
- int outchannels = (sys_outchannels > alsa_outchannels ?
- alsa_outchannels : sys_outchannels);
- unsigned int intransfersize = DEFDACBLKSIZE;
- unsigned int outtransfersize = DEFDACBLKSIZE;
-
- // get the status
- if (!inchannels && !outchannels)
- {
- return SENDDACS_NO;
- }
-
- timelast = timenow;
- timenow = sys_getrealtime();
-
-#ifdef DEBUG_ALSA_XFER
- if (timenow - timelast > 0.050)
- fprintf(stderr, "(%d)",
- (int)(1000 * (timenow - timelast))), fflush(stderr);
-#endif
-
- callno++;
-
- alsa_checkiosync(); /* check I/O are in sync and data not late */
-
- if (alsa_inchannels)
- {
- snd_pcm_status(alsa_device.inhandle, in_status);
- if (snd_pcm_status_get_avail(in_status) < intransfersize)
- return SENDDACS_NO;
- }
- if (alsa_outchannels)
- {
- snd_pcm_status(alsa_device.outhandle, out_status);
- if (snd_pcm_status_get_avail(out_status) < outtransfersize)
- return SENDDACS_NO;
- }
-
- /* do output */
- if (alsa_outchannels)
- {
- fp = sys_soundout;
- if (alsa_samplewidth == 4)
- {
- if (alsa_device.outnoninterleave)
- {
- int n = outchannels * DEFDACBLKSIZE;
- for (i = 0, fp1 = fp; i < n; i++)
- {
- float s1 = *fp1 * INT32_MAX;
- ((t_alsa_sample32 *)alsa_snd_buf)[i] = CLIP32(s1);
- }
- n = alsa_outchannels * DEFDACBLKSIZE;
- for (; i < n; i++)
- ((t_alsa_sample32 *)alsa_snd_buf)[i] = 0;
- }
- else
- {
- for (i = 0, fp1 = fp; i < outchannels; i++,
- fp1 += DEFDACBLKSIZE)
- {
- for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
- j += alsa_outchannels, fp2++)
- {
- float s1 = *fp2 * INT32_MAX;
- ((t_alsa_sample32 *)alsa_snd_buf)[j] = CLIP32(s1);
- }
- }
- }
- }
- else
- {
- for (i = 0, fp1 = fp; i < outchannels; i++, fp1 += DEFDACBLKSIZE)
- {
- for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
- j += alsa_outchannels, fp2++)
- {
- int s = *fp2 * 32767.;
- if (s > 32767)
- s = 32767;
- else if (s < -32767)
- s = -32767;
- ((t_alsa_sample16 *)alsa_snd_buf)[j] = s;
- }
- }
- }
-
- if (alsa_device.outnoninterleave)
- result = snd_pcm_writen(alsa_device.outhandle, alsa_buf_ptrs,
- outtransfersize);
- else result = snd_pcm_writei(alsa_device.outhandle, alsa_snd_buf,
- outtransfersize);
-
- if (result != (int)outtransfersize)
- {
- #ifdef DEBUG_ALSA_XFER
- if (result >= 0 || errno == EAGAIN)
- fprintf(stderr, "ALSA: write returned %d of %d\n",
- result, outtransfersize);
- else fprintf(stderr, "ALSA: write: %s\n",
- snd_strerror(errno));
- fprintf(stderr,
- "inputcount %d, outputcount %d, outbufsize %d\n",
- inputcount, outputcount,
- (ALSA_EXTRABUFFER + sys_advance_samples)
- * alsa_samplewidth * outchannels);
- #endif
- sys_log_error(ERR_DACSLEPT);
- return (SENDDACS_NO);
- }
-
- /* zero out the output buffer */
- memset(sys_soundout, 0, DEFDACBLKSIZE * sizeof(*sys_soundout) *
- sys_outchannels);
- if (sys_getrealtime() - timenow > 0.002)
- {
- #ifdef DEBUG_ALSA_XFER
- fprintf(stderr, "output %d took %d msec\n",
- callno, (int)(1000 * (timenow - timelast))), fflush(stderr);
- #endif
- timenow = sys_getrealtime();
- sys_log_error(ERR_DACSLEPT);
- }
- }
- /* do input */
- if (alsa_inchannels)
- {
- if (alsa_device.innoninterleave)
- result = snd_pcm_readn(alsa_device.inhandle, alsa_buf_ptrs,
- intransfersize);
- else result = snd_pcm_readi(alsa_device.inhandle, alsa_snd_buf,
- intransfersize);
- if (result < (int)intransfersize)
- {
-#ifdef DEBUG_ALSA_XFER
- if (result < 0)
- fprintf(stderr,
- "snd_pcm_read %d %d: %s\n",
- callno, xferno, snd_strerror(errno));
- else fprintf(stderr,
- "snd_pcm_read %d %d returned only %d\n",
- callno, xferno, result);
- fprintf(stderr,
- "inputcount %d, outputcount %d, inbufsize %d\n",
- inputcount, outputcount,
- (ALSA_EXTRABUFFER + sys_advance_samples)
- * alsa_samplewidth * inchannels);
-#endif
- sys_log_error(ERR_ADCSLEPT);
- return (SENDDACS_NO);
- }
- fp = sys_soundin;
- if (alsa_samplewidth == 4)
- {
- if (alsa_device.innoninterleave)
- {
- int n = inchannels * DEFDACBLKSIZE;
- for (i = 0, fp1 = fp; i < n; i++)
- *fp1 = (float) ((t_alsa_sample32 *)alsa_snd_buf)[i]
- * (1./ INT32_MAX);
- }
- else
- {
- for (i = 0, fp1 = fp; i < inchannels;
- i++, fp1 += DEFDACBLKSIZE)
- {
- for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
- j += alsa_inchannels, fp2++)
- *fp2 = (float) ((t_alsa_sample32 *)alsa_snd_buf)[j]
- * (1./ INT32_MAX);
- }
- }
- }
- else
- {
- for (i = 0, fp1 = fp; i < inchannels; i++, fp1 += DEFDACBLKSIZE)
- {
- for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
- j += alsa_inchannels, fp2++)
- *fp2 = (float) ((t_alsa_sample16 *)alsa_snd_buf)[j]
- * 3.051850e-05;
- }
- }
- }
- xferno++;
- if (sys_getrealtime() - timenow > 0.002)
- {
-#ifdef DEBUG_ALSA_XFER
- fprintf(stderr, "routine took %d msec\n",
- (int)(1000 * (sys_getrealtime() - timenow)));
-#endif
- sys_log_error(ERR_ADCSLEPT);
- }
- return SENDDACS_YES;
-}
-
-void alsa_printstate( void)
-{
- int i, result;
- snd_pcm_sframes_t indelay, outdelay;
- if (sys_audioapi != API_ALSA)
- {
- error("restart-audio: implemented for ALSA only.");
- return;
- }
- if (sys_inchannels)
- {
- result = snd_pcm_delay(alsa_device.inhandle, &indelay);
- if (result < 0)
- post("snd_pcm_delay 1 failed");
- else post("in delay %d", indelay);
- }
- if (sys_outchannels)
- {
- result = snd_pcm_delay(alsa_device.outhandle, &outdelay);
- if (result < 0)
- post("snd_pcm_delay 2 failed");
- else post("out delay %d", outdelay);
- }
- post("sum %d (%d mod 64)\n", indelay + outdelay, (indelay+outdelay)%64);
-
- post("buf samples %d", alsa_buf_samps);
-}
-
-
-void alsa_resync( void)
-{
- int i, result;
- if (sys_audioapi != API_ALSA)
- {
- error("restart-audio: implemented for ALSA only.");
- return;
- }
- memset(alsa_snd_buf, 0,
- sizeof(char) * alsa_samplewidth * DEFDACBLKSIZE * sys_outchannels);
- for (i = 0; i < 1000000; i++)
- {
- if (alsa_device.outnoninterleave)
- result = snd_pcm_writen(alsa_device.outhandle, alsa_buf_ptrs,
- DEFDACBLKSIZE);
- else result = snd_pcm_writei(alsa_device.outhandle, alsa_snd_buf,
- DEFDACBLKSIZE);
- if (result != (int)DEFDACBLKSIZE)
- break;
- }
- post("%d written", i);
-}
-
-void alsa_putzeros(int n)
-{
- int i, result;
- memset(alsa_snd_buf, 0,
- sizeof(char) * alsa_samplewidth * DEFDACBLKSIZE * alsa_outchannels);
- for (i = 0; i < n; i++)
- {
- if (alsa_device.outnoninterleave)
- result = snd_pcm_writen(alsa_device.outhandle, alsa_buf_ptrs,
- DEFDACBLKSIZE);
- else result = snd_pcm_writei(alsa_device.outhandle, alsa_snd_buf,
- DEFDACBLKSIZE);
-#if 0
- if (result != DEFDACBLKSIZE)
- post("result %d", result);
-#endif
- }
-}
-
-void alsa_getzeros(int n)
-{
- int i, result;
- for (i = 0; i < n; i++)
- {
- result = snd_pcm_readi(alsa_device.inhandle, alsa_snd_buf,
- DEFDACBLKSIZE);
-#if 0
- if (result != DEFDACBLKSIZE)
- post("result %d", result);
-#endif
- }
-}
-
- /* call this only if both input and output are open */
-static void alsa_checkiosync( void)
-{
- int i, result, checkit = 1, giveup = 1000, alreadylogged = 0;
- snd_pcm_sframes_t indelay, outdelay, defect;
-
- if (!(alsa_outchannels && alsa_inchannels))
- return;
- while (checkit)
- {
- checkit = 0;
- if (giveup-- <= 0)
- return;
- result = snd_pcm_delay(alsa_device.outhandle, &outdelay);
- if (result < 0)
- {
- post("output snd_pcm_delay failed: %s", snd_strerror(result));
- if (snd_pcm_status(alsa_device.outhandle, out_status) < 0)
- post("output snd_pcm_status failed");
- else post("astate %d",
- snd_pcm_status_get_state(out_status));
- return;
- }
- if (outdelay < 0)
- sys_log_error(ERR_DATALATE), alreadylogged = 1;
-
- if (sys_inchannels)
- {
- result = snd_pcm_delay(alsa_device.inhandle, &indelay);
- if (result < 0)
- {
- post("input snd_pcm_delay failed");
- return;
- }
- defect = indelay + outdelay - alsa_buf_samps;
- if (defect < -DEFDACBLKSIZE)
- {
- checkit = 1;
- alsa_putzeros(1);
- if (!alreadylogged)
- sys_log_error(ERR_RESYNC), alreadylogged = 1;
- }
- else if (defect > 0)
- {
- checkit = 1;
- alsa_getzeros(1);
- if (!alreadylogged)
- sys_log_error(ERR_RESYNC), alreadylogged = 1;
- }
- }
- }
-}
-
-void alsa_listdevs( void)
-{
- post("device listing not implemented in ALSA yet\n");
-}
-
-static int alsa_nnames = 0;
-static char **alsa_names = 0;
-
-void alsa_adddev(char *name)
-{
- if (alsa_nnames)
- alsa_names = (char **)t_resizebytes(alsa_names,
- alsa_nnames * sizeof(char *),
- (alsa_nnames+1) * sizeof(char *));
- else alsa_names = (char **)t_getbytes(sizeof(char *));
- alsa_names[alsa_nnames] = gensym(name)->s_name;
- alsa_nnames++;
-}
-
-static void alsa_numbertoname(int devno, char *devname, int nchar)
-{
- int ndev = 0, cardno = -1;
- while (!snd_card_next(&cardno) && cardno >= 0)
- ndev++;
- if (devno < 2*ndev)
- {
- if (devno & 1)
- snprintf(devname, nchar, "plughw:%d", devno/2);
- else snprintf(devname, nchar, "hw:%d", devno/2);
- }
- else if (devno <2*ndev + alsa_nnames)
- snprintf(devname, nchar, "%s", alsa_names[devno - 2*ndev]);
- else snprintf(devname, nchar, "???");
-}
-
- /* For each hardware card found, we list two devices, the "hard" and
- "plug" one. The card scan is derived from portaudio code. */
-void alsa_getdevs(char *indevlist, int *nindevs,
- char *outdevlist, int *noutdevs, int *canmulti,
- int maxndev, int devdescsize)
-{
- int ndev = 0, cardno = -1, i, j;
- *canmulti = 0; /* only one device; must be the same for input&output */
- while (!snd_card_next(&cardno) && cardno >= 0)
- {
- snd_ctl_t *ctl;
- snd_ctl_card_info_t *info;
- char devname[80];
- const char *desc;
- if (2 * ndev + 2 > maxndev)
- break;
- /* apparently, "cardno" is just a counter; but check that here */
- if (ndev != cardno)
- fprintf(stderr, "oops: ALSA cards not reported in order?\n");
- sprintf(devname, "hw:%d", cardno );
- /* fprintf(stderr, "\ntry %s...\n", devname); */
- if (snd_ctl_open(&ctl, devname, 0) >= 0)
- {
- snd_ctl_card_info_malloc(&info);
- snd_ctl_card_info(ctl, info);
- desc = snd_ctl_card_info_get_name(info);
- snd_ctl_card_info_free(info);
- }
- else
- {
- fprintf(stderr, "ALSA card scan error\n");
- desc = "???";
- }
- /* fprintf(stderr, "name: %s\n", snd_ctl_card_info_get_name(info)); */
- sprintf(indevlist + 2*ndev * devdescsize, "%s (hardware)", desc);
- sprintf(indevlist + (2*ndev + 1) * devdescsize, "%s (plug-in)", desc);
- sprintf(outdevlist + 2*ndev * devdescsize, "%s (hardware)", desc);
- sprintf(outdevlist + (2*ndev + 1) * devdescsize, "%s (plug-in)", desc);
- ndev++;
- }
- for (i = 0, j = 2*ndev; i < alsa_nnames; i++, j++)
- {
- if (j >= maxndev)
- break;
- snprintf(indevlist + j * devdescsize, devdescsize, "%s",
- alsa_names[i]);
- }
- *nindevs = *noutdevs = j;
-}