Update of /cvsroot/pure-data/pd/portaudio_v18/pa_mac_core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9652/portaudio_v18/pa_mac_core
Modified Files:
notes.txt pa_mac_core.c
Log Message:
checking in version 0.38test5.
Oops, I realize I forgot some more nice files, will add them and re-commit.
Index: notes.txt
===================================================================
RCS file: /cvsroot/pure-data/pd/portaudio_v18/pa_mac_core/notes.txt,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** notes.txt 9 May 2003 16:03:59 -0000 1.1.1.1
--- notes.txt 6 Sep 2004 20:20:30 -0000 1.2
***************
*** 33,34 ****
--- 33,36 ----
we scan the list and add a PortAudio device for each CoreAudio device
that supports input. Then we make a scan for output devices.
+
+ (minor change to test CVS)
Index: pa_mac_core.c
===================================================================
RCS file: /cvsroot/pure-data/pd/portaudio_v18/pa_mac_core/pa_mac_core.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pa_mac_core.c 22 Feb 2004 16:21:31 -0000 1.2
--- pa_mac_core.c 6 Sep 2004 20:20:30 -0000 1.3
***************
*** 109,112 ****
--- 109,117 ----
04.16.2003 - Phil Burk - Fixed input channel scrambling when numChannels != 2^N. Caused by alignment
error when filling RingBuffer with 2^N zero bytes.
+ 04.26.2003 - Phil Burk - Removed code to turn up volume and unmute to prevent blown eardrums.
+ 12.08.2003 - Phil Burk - Move declaration of oldConverter to top of PAOSX_DevicePropertyListener()
+ 12.08.2003 - Phil Burk - Removed need for #include "pa_trace.h", just for debug
+ 12.09.2003 - Phil Burk - Only change sampleRate or numChannels if we need to improve over
+ current setting.
*/
***************
*** 115,119 ****
#include <sys/time.h>
#include <sys/resource.h>
- #include <unistd.h>
#include <AudioUnit/AudioUnit.h>
#include <AudioToolbox/DefaultAudioOutput.h>
--- 120,123 ----
***************
*** 123,127 ****
#include "portaudio.h"
#include "pa_host.h"
- #include "pa_trace.h"
#include "ringbuffer.h"
--- 127,130 ----
***************
*** 796,800 ****
{
/* Clear remainder of audio buffer if we are waiting for stop. */
- AddTraceMessage("PaOSX_LoadAndProcess: zero rest of wave buffer ", i );
memset( outputBuffer, 0, pahsc->output.bytesPerUserNativeBuffer );
}
--- 799,802 ----
***************
*** 1219,1227 ****
originalChannels = formatDesc.mChannelsPerFrame;
! // Is it already set to the correct format?
! if( (originalRate != desiredRate) || (originalChannels != desiredNumChannels) )
{
! DBUG(("PaOSX_SetFormat: try to change sample rate to %f.\n", desiredRate ));
! DBUG(("PaOSX_SetFormat: try to set number of channels to %d\n", desiredNumChannels));
formatDesc.mSampleRate = desiredRate;
--- 1221,1231 ----
originalChannels = formatDesc.mChannelsPerFrame;
! // Changing the format can mess up other apps.
! // So only change the format if the original format
! // has a lower sample rate, or fewer channels, than the desired format.
! if( (originalRate < desiredRate) || (originalChannels < desiredNumChannels) )
{
! DBUG(("PaOSX_SetFormat: try to change sample rate from %f to %f.\n", originalRate, desiredRate ));
! DBUG(("PaOSX_SetFormat: try to set number of channels %d to %d\n", originalChannels, desiredNumChannels));
formatDesc.mSampleRate = desiredRate;
***************
*** 1257,1330 ****
}
- /*******************************************************************
- * Check volume level of device. If below threshold, then set to newLevel.
- * Using volume instead of decibels because decibel range varies by device.
- */
- static void PaOSX_FixVolumeScalars( AudioDeviceID devID, Boolean isInput,
- int numChannels, double threshold, double newLevel )
- {
- OSStatus err = noErr;
- UInt32 dataSize;
- int iChannel;
-
- /* The master channel is 0. Left and right are channels 1 and 2. */
- /* Fix volume. */
- for( iChannel = 0; iChannel<=numChannels; iChannel++ )
- {
- Float32 fdata32;
- dataSize = sizeof( fdata32 );
- err = AudioDeviceGetProperty( devID, iChannel, isInput,
- kAudioDevicePropertyVolumeScalar, &dataSize, &fdata32 );
- if( err == noErr )
- {
- DBUG(("kAudioDevicePropertyVolumeScalar for channel %d = %f\n", iChannel, fdata32));
- if( fdata32 <= (Float32) threshold )
- {
- dataSize = sizeof( fdata32 );
- fdata32 = (Float32) newLevel;
- err = AudioDeviceSetProperty( devID, 0, iChannel, isInput,
- kAudioDevicePropertyVolumeScalar, dataSize, &fdata32 );
- if( err != noErr )
- {
- PRINT(("Warning: audio volume is very low and could not be turned up.\n"));
- }
- else
- {
- PRINT(("Volume for audio channel %d was <= %4.2f so set to %4.2f by PortAudio!\n",
- iChannel, threshold, newLevel ));
- }
- }
- }
- }
- /* Unmute if muted. */
- for( iChannel = 0; iChannel<=numChannels; iChannel++ )
- {
- UInt32 uidata32;
- dataSize = sizeof( uidata32 );
- err = AudioDeviceGetProperty( devID, iChannel, isInput,
- kAudioDevicePropertyMute, &dataSize, &uidata32 );
- if( err == noErr )
- {
- DBUG(("mute for channel %d = %ld\n", iChannel, uidata32));
- if( uidata32 == 1 ) // muted?
- {
- dataSize = sizeof( uidata32 );
- uidata32 = 0; // unmute
- err = AudioDeviceSetProperty( devID, 0, iChannel, isInput,
- kAudioDevicePropertyMute, dataSize, &uidata32 );
- if( err != noErr )
- {
- PRINT(("Warning: audio is muted and could not be unmuted!\n"));
- }
- else
- {
- PRINT(("Audio channel %d was unmuted by PortAudio!\n", iChannel ));
- }
- }
- }
- }
-
- }
-
#if 0
static void PaOSX_DumpDeviceInfo( AudioDeviceID devID, Boolean isInput )
--- 1261,1264 ----
***************
*** 1414,1417 ****
--- 1348,1352 ----
PaHostInOut *hostInOut;
AudioStreamBasicDescription *destFormatPtr, *srcFormatPtr;
+ AudioConverterRef oldConverter = NULL; // PLB 20031208 - Declare here for standard 'C'.
past = (internalPortAudioStream *) inClientData;
***************
*** 1466,1470 ****
// Don't delete old converter until we create new one so we don't pull
// the rug out from under other audio threads.
! AudioConverterRef oldConverter = hostInOut->converter;
// Make converter to change sample rate.
--- 1401,1405 ----
// Don't delete old converter until we create new one so we don't pull
// the rug out from under other audio threads.
! oldConverter = hostInOut->converter;
// Make converter to change sample rate.
***************
*** 1596,1601 ****
Float64 deviceRate;
- PaOSX_FixVolumeScalars( inOut->audioDeviceID, isInput,
- inOut->numChannels, 0.1, 0.9 );
// The HW device format changes are asynchronous.
--- 1531,1534 ----