Cocoa Port:
- Add the Microphone Settings panel for easier control and more verbose info. The new panel also allows the user to change and monitor mic settings without needing a display window's status bar. - Implement a more proper mic level UI that reports the level per frame instead of per sample. This should improve UI performance. - Make all methods in the CocoaDSControllerDelegate protocol optional and remove all related protocol methods from the OpenEmu plug-in. - Try attaching a new hardware input device on startup. - Remove debug printf stuff when attaching a new hardware input device. The new Microphone Settings panel makes the extra printf stuff unnecessary. - Remember the hardware mic mute setting between app launches.
This commit is contained in:
parent
d0ec648952
commit
fa4d2cb58f
|
@ -694,6 +694,8 @@
|
||||||
<dict/>
|
<dict/>
|
||||||
<key>Input_SavedProfiles</key>
|
<key>Input_SavedProfiles</key>
|
||||||
<array/>
|
<array/>
|
||||||
|
<key>Microphone_HardwareMicMute</key>
|
||||||
|
<false/>
|
||||||
<key>Render3D_DepthComparisonThreshold</key>
|
<key>Render3D_DepthComparisonThreshold</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>Render3D_EdgeMarking</key>
|
<key>Render3D_EdgeMarking</key>
|
||||||
|
|
|
@ -901,6 +901,8 @@ volatile bool execute = true;
|
||||||
[self setCoreState:CORESTATE_PAUSE];
|
[self setCoreState:CORESTATE_PAUSE];
|
||||||
[self applyDynaRec];
|
[self applyDynaRec];
|
||||||
[self applySlot1Device];
|
[self applySlot1Device];
|
||||||
|
[[self cdsController] resetMicLevel];
|
||||||
|
[[self cdsController] updateMicLevel];
|
||||||
|
|
||||||
pthread_mutex_lock(&threadParam.mutexThreadExecute);
|
pthread_mutex_lock(&threadParam.mutexThreadExecute);
|
||||||
NDS_Reset();
|
NDS_Reset();
|
||||||
|
@ -1128,15 +1130,8 @@ static void* RunCoreThread(void *arg)
|
||||||
|
|
||||||
// Make sure that the mic level is updated at least once per frame, regardless
|
// Make sure that the mic level is updated at least once per frame, regardless
|
||||||
// of whether the NDS actually reads the mic or not.
|
// of whether the NDS actually reads the mic or not.
|
||||||
if (![cdsController isHardwareMicReadThisFrame])
|
[cdsController updateMicLevel];
|
||||||
{
|
[cdsController resetMicLevel];
|
||||||
[cdsController updateHardwareMicLevelWithSample:MIC_NULL_SAMPLE_VALUE];
|
|
||||||
[[cdsController delegate] doMicSamplesReadFromController:cdsController inSample:MIC_NULL_SAMPLE_VALUE];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[cdsController setIsHardwareMicReadThisFrame:NO];
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_lock(¶m->mutexOutputList);
|
pthread_mutex_lock(¶m->mutexOutputList);
|
||||||
|
|
||||||
|
|
|
@ -249,10 +249,8 @@
|
||||||
#define MIC_SAMPLE_SIZE ((MIC_SAMPLE_RESOLUTION / 8) * MIC_NUMBER_CHANNELS) // Bytes per sample, multiplied by the number of channels
|
#define MIC_SAMPLE_SIZE ((MIC_SAMPLE_RESOLUTION / 8) * MIC_NUMBER_CHANNELS) // Bytes per sample, multiplied by the number of channels
|
||||||
#define MIC_MAX_BUFFER_SAMPLES ((MIC_SAMPLE_RATE / DS_FRAMES_PER_SECOND) * MIC_SAMPLE_SIZE)
|
#define MIC_MAX_BUFFER_SAMPLES ((MIC_SAMPLE_RATE / DS_FRAMES_PER_SECOND) * MIC_SAMPLE_SIZE)
|
||||||
#define MIC_CAPTURE_FRAMES 192 // The number of audio frames that the NDS microphone should pull. The lower this value, the lower the latency. Ensure that this value is not too low, or else audio frames may be lost.
|
#define MIC_CAPTURE_FRAMES 192 // The number of audio frames that the NDS microphone should pull. The lower this value, the lower the latency. Ensure that this value is not too low, or else audio frames may be lost.
|
||||||
#define MIC_CLIP_FRAME_THRESHOLD 15 // When the number of clipped mic samples reaches this amount, the UI will reflect that the mic is clipping.
|
#define MIC_NULL_LEVEL_THRESHOLD 3
|
||||||
#define MIC_CLIP_FRAME_MAX_COUNT 60 // When counting clipped mic samples, don't count past this number. This is to prevent the mic clip state from persisting too long after the mic has stopped clipping.
|
#define MIC_CLIP_LEVEL_THRESHOLD 59
|
||||||
#define MIC_NULL_FRAME_THRESHOLD 12 // When the number of null mic samples reaches this amount, the UI will reflect that the mic is null.
|
|
||||||
#define MIC_NULL_FRAME_MAX_COUNT 24 // When counting null mic samples, don't count past this number. This is to prevent the mic null state from persisting too long after the mic has read some samples.
|
|
||||||
#define MIC_NULL_SAMPLE_VALUE 64
|
#define MIC_NULL_SAMPLE_VALUE 64
|
||||||
|
|
||||||
#define COCOA_DIALOG_CANCEL 0
|
#define COCOA_DIALOG_CANCEL 0
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#include <libkern/OSAtomic.h>
|
#include <libkern/OSAtomic.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
@class CocoaDSController;
|
@class CocoaDSController;
|
||||||
class CoreAudioInput;
|
class CoreAudioInput;
|
||||||
|
@ -77,10 +78,8 @@ typedef struct
|
||||||
|
|
||||||
@protocol CocoaDSControllerDelegate <NSObject>
|
@protocol CocoaDSControllerDelegate <NSObject>
|
||||||
|
|
||||||
@required
|
|
||||||
- (uint8_t) doMicSamplesReadFromController:(CocoaDSController *)cdsController inSample:(uint8_t)sampleValue;
|
|
||||||
|
|
||||||
@optional
|
@optional
|
||||||
|
- (void) doMicLevelUpdateFromController:(CocoaDSController *)cdsController;
|
||||||
- (void) doMicHardwareStateChangedFromController:(CocoaDSController *)cdsController
|
- (void) doMicHardwareStateChangedFromController:(CocoaDSController *)cdsController
|
||||||
isEnabled:(BOOL)isHardwareEnabled
|
isEnabled:(BOOL)isHardwareEnabled
|
||||||
isLocked:(BOOL)isHardwareLocked
|
isLocked:(BOOL)isHardwareLocked
|
||||||
|
@ -93,13 +92,12 @@ typedef struct
|
||||||
@interface CocoaDSController : NSObject
|
@interface CocoaDSController : NSObject
|
||||||
{
|
{
|
||||||
id <CocoaDSControllerDelegate> delegate;
|
id <CocoaDSControllerDelegate> delegate;
|
||||||
BOOL isHardwareMicReadThisFrame;
|
float micLevel;
|
||||||
BOOL autohold;
|
BOOL autohold;
|
||||||
BOOL isAutoholdCleared;
|
BOOL isAutoholdCleared;
|
||||||
BOOL _useHardwareMic;
|
BOOL _useHardwareMic;
|
||||||
size_t _availableMicSamples;
|
size_t _availableMicSamples;
|
||||||
uint32_t _hwMicNumberIdleFrames;
|
std::vector<uint8_t> *_hwMicLevelList;
|
||||||
uint32_t _hwMicNumberClippedFrames;
|
|
||||||
NSInteger micMode;
|
NSInteger micMode;
|
||||||
NSPoint touchLocation;
|
NSPoint touchLocation;
|
||||||
|
|
||||||
|
@ -108,7 +106,11 @@ typedef struct
|
||||||
CoreAudioInput *CAInputDevice;
|
CoreAudioInput *CAInputDevice;
|
||||||
AudioGenerator *softwareMicSampleGenerator;
|
AudioGenerator *softwareMicSampleGenerator;
|
||||||
NSInteger paddleAdjust;
|
NSInteger paddleAdjust;
|
||||||
|
|
||||||
NSString *hardwareMicInfoString;
|
NSString *hardwareMicInfoString;
|
||||||
|
NSString *hardwareMicNameString;
|
||||||
|
NSString *hardwareMicManufacturerString;
|
||||||
|
NSString *hardwareMicSampleRateString;
|
||||||
|
|
||||||
OSSpinLock spinlockControllerState;
|
OSSpinLock spinlockControllerState;
|
||||||
}
|
}
|
||||||
|
@ -116,9 +118,9 @@ typedef struct
|
||||||
@property (retain) id <CocoaDSControllerDelegate> delegate;
|
@property (retain) id <CocoaDSControllerDelegate> delegate;
|
||||||
@property (assign) BOOL autohold;
|
@property (assign) BOOL autohold;
|
||||||
@property (readonly) BOOL isHardwareMicAvailable;
|
@property (readonly) BOOL isHardwareMicAvailable;
|
||||||
@property (assign) BOOL isHardwareMicIdle;
|
@property (readonly) BOOL isHardwareMicIdle;
|
||||||
@property (assign) BOOL isHardwareMicInClip;
|
@property (readonly) BOOL isHardwareMicInClip;
|
||||||
@property (assign) BOOL isHardwareMicReadThisFrame;
|
@property (assign) float micLevel;
|
||||||
@property (assign) BOOL hardwareMicEnabled;
|
@property (assign) BOOL hardwareMicEnabled;
|
||||||
@property (readonly) BOOL hardwareMicLocked;
|
@property (readonly) BOOL hardwareMicLocked;
|
||||||
@property (assign) float hardwareMicGain;
|
@property (assign) float hardwareMicGain;
|
||||||
|
@ -132,6 +134,9 @@ typedef struct
|
||||||
@property (assign) AudioSampleBlockGenerator *selectedAudioFileGenerator;
|
@property (assign) AudioSampleBlockGenerator *selectedAudioFileGenerator;
|
||||||
@property (assign) NSInteger paddleAdjust;
|
@property (assign) NSInteger paddleAdjust;
|
||||||
@property (retain) NSString *hardwareMicInfoString;
|
@property (retain) NSString *hardwareMicInfoString;
|
||||||
|
@property (retain) NSString *hardwareMicNameString;
|
||||||
|
@property (retain) NSString *hardwareMicManufacturerString;
|
||||||
|
@property (retain) NSString *hardwareMicSampleRateString;
|
||||||
|
|
||||||
- (void) setControllerState:(BOOL)theState controlID:(const NSUInteger)controlID;
|
- (void) setControllerState:(BOOL)theState controlID:(const NSUInteger)controlID;
|
||||||
- (void) setControllerState:(BOOL)theState controlID:(const NSUInteger)controlID turbo:(const BOOL)isTurboEnabled;
|
- (void) setControllerState:(BOOL)theState controlID:(const NSUInteger)controlID turbo:(const BOOL)isTurboEnabled;
|
||||||
|
@ -140,7 +145,9 @@ typedef struct
|
||||||
- (void) clearAutohold;
|
- (void) clearAutohold;
|
||||||
- (void) flush;
|
- (void) flush;
|
||||||
- (void) flushEmpty;
|
- (void) flushEmpty;
|
||||||
- (void) updateHardwareMicLevelWithSample:(uint8_t)inSample;
|
|
||||||
|
- (void) resetMicLevel;
|
||||||
|
- (void) updateMicLevel;
|
||||||
- (uint8_t) handleMicSampleRead:(CoreAudioInput *)caInput softwareMic:(AudioGenerator *)sampleGenerator;
|
- (uint8_t) handleMicSampleRead:(CoreAudioInput *)caInput softwareMic:(AudioGenerator *)sampleGenerator;
|
||||||
- (void) handleMicHardwareStateChanged:(CoreAudioInputDeviceInfo *)deviceInfo
|
- (void) handleMicHardwareStateChanged:(CoreAudioInputDeviceInfo *)deviceInfo
|
||||||
isEnabled:(BOOL)isHardwareEnabled
|
isEnabled:(BOOL)isHardwareEnabled
|
||||||
|
|
|
@ -38,7 +38,7 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
||||||
@dynamic isHardwareMicAvailable;
|
@dynamic isHardwareMicAvailable;
|
||||||
@dynamic isHardwareMicIdle;
|
@dynamic isHardwareMicIdle;
|
||||||
@dynamic isHardwareMicInClip;
|
@dynamic isHardwareMicInClip;
|
||||||
@synthesize isHardwareMicReadThisFrame;
|
@synthesize micLevel;
|
||||||
@dynamic hardwareMicEnabled;
|
@dynamic hardwareMicEnabled;
|
||||||
@dynamic hardwareMicLocked;
|
@dynamic hardwareMicLocked;
|
||||||
@dynamic hardwareMicGain;
|
@dynamic hardwareMicGain;
|
||||||
|
@ -53,6 +53,9 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
||||||
@synthesize selectedAudioFileGenerator;
|
@synthesize selectedAudioFileGenerator;
|
||||||
@synthesize paddleAdjust;
|
@synthesize paddleAdjust;
|
||||||
@synthesize hardwareMicInfoString;
|
@synthesize hardwareMicInfoString;
|
||||||
|
@synthesize hardwareMicNameString;
|
||||||
|
@synthesize hardwareMicManufacturerString;
|
||||||
|
@synthesize hardwareMicSampleRateString;
|
||||||
|
|
||||||
- (id)init
|
- (id)init
|
||||||
{
|
{
|
||||||
|
@ -74,11 +77,13 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
||||||
spinlockControllerState = OS_SPINLOCK_INIT;
|
spinlockControllerState = OS_SPINLOCK_INIT;
|
||||||
autohold = NO;
|
autohold = NO;
|
||||||
isAutoholdCleared = YES;
|
isAutoholdCleared = YES;
|
||||||
isHardwareMicReadThisFrame = NO;
|
micLevel = 0.0f;
|
||||||
_useHardwareMic = NO;
|
_useHardwareMic = NO;
|
||||||
_availableMicSamples = 0;
|
_availableMicSamples = 0;
|
||||||
_hwMicNumberIdleFrames = MIC_NULL_FRAME_THRESHOLD;
|
|
||||||
_hwMicNumberClippedFrames = 0;
|
_hwMicLevelList = new std::vector<uint8_t>;
|
||||||
|
_hwMicLevelList->reserve(1024);
|
||||||
|
_hwMicLevelList->clear();
|
||||||
|
|
||||||
micMode = MICMODE_NONE;
|
micMode = MICMODE_NONE;
|
||||||
selectedAudioFileGenerator = NULL;
|
selectedAudioFileGenerator = NULL;
|
||||||
|
@ -88,7 +93,11 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
||||||
softwareMicSampleGenerator = &nullSampleGenerator;
|
softwareMicSampleGenerator = &nullSampleGenerator;
|
||||||
touchLocation = NSMakePoint(0.0f, 0.0f);
|
touchLocation = NSMakePoint(0.0f, 0.0f);
|
||||||
paddleAdjust = 0;
|
paddleAdjust = 0;
|
||||||
|
|
||||||
hardwareMicInfoString = @"No hardware input detected.";
|
hardwareMicInfoString = @"No hardware input detected.";
|
||||||
|
hardwareMicNameString = @"No hardware input detected.";
|
||||||
|
hardwareMicManufacturerString = @"No hardware input detected.";
|
||||||
|
hardwareMicSampleRateString = @"No hardware input detected.";
|
||||||
|
|
||||||
Mic_SetResetCallback(&CAResetCallback, self, NULL);
|
Mic_SetResetCallback(&CAResetCallback, self, NULL);
|
||||||
Mic_SetSampleReadCallback(&CASampleReadCallback, self, NULL);
|
Mic_SetSampleReadCallback(&CASampleReadCallback, self, NULL);
|
||||||
|
@ -99,6 +108,7 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
delete CAInputDevice;
|
delete CAInputDevice;
|
||||||
|
delete _hwMicLevelList;
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,40 +119,14 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
||||||
!CAInputDevice->GetPauseState() ) ? YES : NO;
|
!CAInputDevice->GetPauseState() ) ? YES : NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setIsHardwareMicIdle:(BOOL)theState
|
|
||||||
{
|
|
||||||
if (theState)
|
|
||||||
{
|
|
||||||
_hwMicNumberIdleFrames = MIC_NULL_FRAME_THRESHOLD;
|
|
||||||
_hwMicNumberClippedFrames = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_hwMicNumberIdleFrames = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL) isHardwareMicIdle
|
- (BOOL) isHardwareMicIdle
|
||||||
{
|
{
|
||||||
return (_hwMicNumberIdleFrames >= MIC_NULL_FRAME_THRESHOLD);
|
return (micLevel < MIC_NULL_LEVEL_THRESHOLD);
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setIsHardwareMicInClip:(BOOL)theState
|
|
||||||
{
|
|
||||||
if (theState)
|
|
||||||
{
|
|
||||||
_hwMicNumberIdleFrames = 0;
|
|
||||||
_hwMicNumberClippedFrames = MIC_CLIP_FRAME_THRESHOLD;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_hwMicNumberClippedFrames = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) isHardwareMicInClip
|
- (BOOL) isHardwareMicInClip
|
||||||
{
|
{
|
||||||
return (_hwMicNumberClippedFrames >= MIC_CLIP_FRAME_THRESHOLD);
|
return (micLevel >= MIC_CLIP_LEVEL_THRESHOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setHardwareMicEnabled:(BOOL)micEnabled
|
- (void) setHardwareMicEnabled:(BOOL)micEnabled
|
||||||
|
@ -526,42 +510,35 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
||||||
NDS_setMic(false);
|
NDS_setMic(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updateHardwareMicLevelWithSample:(uint8_t)inSample
|
- (void) resetMicLevel
|
||||||
{
|
{
|
||||||
switch (inSample)
|
_hwMicLevelList->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) updateMicLevel
|
||||||
|
{
|
||||||
|
float avgMicLevel = 0.0f;
|
||||||
|
size_t recordedLevelCount = _hwMicLevelList->size();
|
||||||
|
|
||||||
|
for(size_t i = 0; i < recordedLevelCount; i++)
|
||||||
{
|
{
|
||||||
case MIC_NULL_SAMPLE_VALUE:
|
avgMicLevel += (*_hwMicLevelList)[i];
|
||||||
{
|
}
|
||||||
if (_hwMicNumberIdleFrames < MIC_NULL_FRAME_MAX_COUNT)
|
|
||||||
{
|
|
||||||
_hwMicNumberIdleFrames++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 0:
|
if (recordedLevelCount > 0)
|
||||||
case 127:
|
{
|
||||||
{
|
avgMicLevel /= _hwMicLevelList->size();
|
||||||
if (_hwMicNumberClippedFrames < MIC_CLIP_FRAME_MAX_COUNT)
|
}
|
||||||
{
|
else
|
||||||
_hwMicNumberClippedFrames++;
|
{
|
||||||
}
|
avgMicLevel = 0.0f;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
[self setMicLevel:avgMicLevel];
|
||||||
{
|
|
||||||
if (_hwMicNumberIdleFrames > 0)
|
|
||||||
{
|
|
||||||
_hwMicNumberIdleFrames--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_hwMicNumberClippedFrames > 0)
|
if (delegate != nil && [delegate respondsToSelector:@selector(doMicLevelUpdateFromController:)])
|
||||||
{
|
{
|
||||||
_hwMicNumberClippedFrames--;
|
[[self delegate] doMicLevelUpdateFromController:self];
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,9 +562,6 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
||||||
caInput->_samplesConverted->read(&theSample, 1);
|
caInput->_samplesConverted->read(&theSample, 1);
|
||||||
theSample >>= 1; // Samples from CoreAudio are 8-bit, so we need to convert the sample to 7-bit
|
theSample >>= 1; // Samples from CoreAudio are 8-bit, so we need to convert the sample to 7-bit
|
||||||
_availableMicSamples--;
|
_availableMicSamples--;
|
||||||
|
|
||||||
[self updateHardwareMicLevelWithSample:theSample];
|
|
||||||
[self setIsHardwareMicReadThisFrame:YES];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -595,7 +569,8 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
||||||
theSample = sampleGenerator->generateSample();
|
theSample = sampleGenerator->generateSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
return [[self delegate] doMicSamplesReadFromController:self inSample:theSample];
|
_hwMicLevelList->push_back(abs((float)theSample - MIC_NULL_SAMPLE_VALUE));
|
||||||
|
return theSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) handleMicHardwareStateChanged:(CoreAudioInputDeviceInfo *)deviceInfo
|
- (void) handleMicHardwareStateChanged:(CoreAudioInputDeviceInfo *)deviceInfo
|
||||||
|
@ -603,21 +578,25 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
||||||
isLocked:(BOOL)isHardwareLocked
|
isLocked:(BOOL)isHardwareLocked
|
||||||
isMuted:(BOOL)isHardwareMuted
|
isMuted:(BOOL)isHardwareMuted
|
||||||
{
|
{
|
||||||
NSString *newHWMicInfoString;
|
|
||||||
if (deviceInfo->objectID == kAudioObjectUnknown)
|
if (deviceInfo->objectID == kAudioObjectUnknown)
|
||||||
{
|
{
|
||||||
newHWMicInfoString = @"No hardware input detected.";
|
[self setHardwareMicInfoString:@"No hardware input detected."];
|
||||||
|
[self setHardwareMicNameString:@"No hardware input detected."];
|
||||||
|
[self setHardwareMicManufacturerString:@"No hardware input detected."];
|
||||||
|
[self setHardwareMicSampleRateString:@"No hardware input detected."];
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newHWMicInfoString = [NSString stringWithFormat:@"%@\nSample Rate: %1.1f Hz",
|
[self setHardwareMicInfoString:[NSString stringWithFormat:@"%@\nSample Rate: %1.1f Hz",
|
||||||
(NSString *)deviceInfo->name,
|
(NSString *)deviceInfo->name,
|
||||||
(double)deviceInfo->sampleRate];
|
(double)deviceInfo->sampleRate]];
|
||||||
|
[self setHardwareMicNameString:(NSString *)deviceInfo->name];
|
||||||
|
[self setHardwareMicManufacturerString:(NSString *)deviceInfo->manufacturer];
|
||||||
|
[self setHardwareMicSampleRateString:[NSString stringWithFormat:@"%1.1f Hz", (double)deviceInfo->sampleRate]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self setHardwareMicInfoString:newHWMicInfoString];
|
[self resetMicLevel];
|
||||||
[self setIsHardwareMicIdle:YES];
|
|
||||||
[self setIsHardwareMicInClip:NO];
|
|
||||||
|
|
||||||
if (delegate != nil && [delegate respondsToSelector:@selector(doMicHardwareStateChangedFromController:isEnabled:isLocked:isMuted:)])
|
if (delegate != nil && [delegate respondsToSelector:@selector(doMicHardwareStateChangedFromController:isEnabled:isLocked:isMuted:)])
|
||||||
{
|
{
|
||||||
|
|
|
@ -300,22 +300,17 @@ OSStatus CoreAudioInput::InitInputAUHAL(UInt32 deviceID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get some information about the device before attempting to attach it to the AUHAL.
|
// Get some information about the device before attempting to attach it to the AUHAL.
|
||||||
// Currently, this information is only available in debug mode. However, if there is
|
|
||||||
// a need to actually do something with this information, then we've already got it.
|
|
||||||
AudioObjectPropertyAddress deviceProperty;
|
AudioObjectPropertyAddress deviceProperty;
|
||||||
UInt32 dataSize = 0;
|
UInt32 dataSize = 0;
|
||||||
deviceProperty.mScope = kAudioObjectPropertyScopeGlobal;
|
deviceProperty.mScope = kAudioObjectPropertyScopeGlobal;
|
||||||
deviceProperty.mElement = kAudioObjectPropertyElementMaster;
|
deviceProperty.mElement = kAudioObjectPropertyElementMaster;
|
||||||
printf("\nInput Device Information:\n");
|
|
||||||
printf(" Object ID: %d\n", deviceID);
|
|
||||||
|
|
||||||
deviceProperty.mSelector = kAudioObjectPropertyName;
|
deviceProperty.mSelector = kAudioObjectPropertyName;
|
||||||
error = AudioObjectGetPropertyDataSize(deviceID, &deviceProperty, 0, NULL, &dataSize);
|
error = AudioObjectGetPropertyDataSize(deviceID, &deviceProperty, 0, NULL, &dataSize);
|
||||||
if (error == noErr)
|
if (error == noErr)
|
||||||
{
|
{
|
||||||
CFRelease(this->_hwDeviceInfo.name);
|
CFRelease(this->_hwDeviceInfo.name);
|
||||||
error = AudioObjectGetPropertyData(deviceID, &deviceProperty, 0, NULL, &dataSize, &this->_hwDeviceInfo.name);
|
AudioObjectGetPropertyData(deviceID, &deviceProperty, 0, NULL, &dataSize, &this->_hwDeviceInfo.name);
|
||||||
printf(" Name: %s\n", CFStringGetCStringPtr(this->_hwDeviceInfo.name, kCFStringEncodingUTF8));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceProperty.mSelector = kAudioObjectPropertyManufacturer;
|
deviceProperty.mSelector = kAudioObjectPropertyManufacturer;
|
||||||
|
@ -323,8 +318,7 @@ OSStatus CoreAudioInput::InitInputAUHAL(UInt32 deviceID)
|
||||||
if (error == noErr)
|
if (error == noErr)
|
||||||
{
|
{
|
||||||
CFRelease(this->_hwDeviceInfo.manufacturer);
|
CFRelease(this->_hwDeviceInfo.manufacturer);
|
||||||
error = AudioObjectGetPropertyData(deviceID, &deviceProperty, 0, NULL, &dataSize, &this->_hwDeviceInfo.manufacturer);
|
AudioObjectGetPropertyData(deviceID, &deviceProperty, 0, NULL, &dataSize, &this->_hwDeviceInfo.manufacturer);
|
||||||
printf(" Manufacturer: %s\n", CFStringGetCStringPtr(this->_hwDeviceInfo.manufacturer, kCFStringEncodingUTF8));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceProperty.mSelector = kAudioDevicePropertyDeviceUID;
|
deviceProperty.mSelector = kAudioDevicePropertyDeviceUID;
|
||||||
|
@ -332,8 +326,7 @@ OSStatus CoreAudioInput::InitInputAUHAL(UInt32 deviceID)
|
||||||
if (error == noErr)
|
if (error == noErr)
|
||||||
{
|
{
|
||||||
CFRelease(this->_hwDeviceInfo.deviceUID);
|
CFRelease(this->_hwDeviceInfo.deviceUID);
|
||||||
error = AudioObjectGetPropertyData(deviceID, &deviceProperty, 0, NULL, &dataSize, &this->_hwDeviceInfo.deviceUID);
|
AudioObjectGetPropertyData(deviceID, &deviceProperty, 0, NULL, &dataSize, &this->_hwDeviceInfo.deviceUID);
|
||||||
printf(" Device UID: %s\n", CFStringGetCStringPtr(this->_hwDeviceInfo.deviceUID, kCFStringEncodingUTF8));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceProperty.mSelector = kAudioDevicePropertyModelUID;
|
deviceProperty.mSelector = kAudioDevicePropertyModelUID;
|
||||||
|
@ -341,8 +334,7 @@ OSStatus CoreAudioInput::InitInputAUHAL(UInt32 deviceID)
|
||||||
if (error == noErr)
|
if (error == noErr)
|
||||||
{
|
{
|
||||||
CFRelease(this->_hwDeviceInfo.modelUID);
|
CFRelease(this->_hwDeviceInfo.modelUID);
|
||||||
error = AudioObjectGetPropertyData(deviceID, &deviceProperty, 0, NULL, &dataSize, &this->_hwDeviceInfo.modelUID);
|
AudioObjectGetPropertyData(deviceID, &deviceProperty, 0, NULL, &dataSize, &this->_hwDeviceInfo.modelUID);
|
||||||
printf(" Model UID: %s\n", CFStringGetCStringPtr(this->_hwDeviceInfo.modelUID, kCFStringEncodingUTF8));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceProperty.mSelector = kAudioDevicePropertyNominalSampleRate;
|
deviceProperty.mSelector = kAudioDevicePropertyNominalSampleRate;
|
||||||
|
@ -350,8 +342,7 @@ OSStatus CoreAudioInput::InitInputAUHAL(UInt32 deviceID)
|
||||||
error = AudioObjectGetPropertyDataSize(deviceID, &deviceProperty, 0, NULL, &dataSize);
|
error = AudioObjectGetPropertyDataSize(deviceID, &deviceProperty, 0, NULL, &dataSize);
|
||||||
if (error == noErr)
|
if (error == noErr)
|
||||||
{
|
{
|
||||||
error = AudioObjectGetPropertyData(deviceID, &deviceProperty, 0, NULL, &dataSize, &this->_hwDeviceInfo.sampleRate);
|
AudioObjectGetPropertyData(deviceID, &deviceProperty, 0, NULL, &dataSize, &this->_hwDeviceInfo.sampleRate);
|
||||||
printf(" Sample Rate: %1.1f\n\n", this->_hwDeviceInfo.sampleRate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before attaching the HAL input device, stop everything first.
|
// Before attaching the HAL input device, stop everything first.
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
@class CocoaDSFirmware;
|
@class CocoaDSFirmware;
|
||||||
|
|
||||||
|
|
||||||
@interface NDSGameCore : OEGameCore <CocoaDSControllerDelegate>
|
@interface NDSGameCore : OEGameCore
|
||||||
{
|
{
|
||||||
NSPoint touchLocation;
|
NSPoint touchLocation;
|
||||||
NSMutableDictionary *addedCheatsDict;
|
NSMutableDictionary *addedCheatsDict;
|
||||||
|
|
|
@ -488,13 +488,4 @@ volatile bool execute = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark CocoaDSControllerDelegate Protocol
|
|
||||||
|
|
||||||
- (uint8_t) doMicSamplesReadFromController:(CocoaDSController *)cdsController inSample:(uint8_t)sampleValue
|
|
||||||
{
|
|
||||||
// Do nothing.
|
|
||||||
// OpenEmu has no UI to reflect changes with the NDS microphone input.
|
|
||||||
return sampleValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -471,6 +471,7 @@
|
||||||
</array>
|
</array>
|
||||||
<reference key="NSMenuFont" ref="844216569"/>
|
<reference key="NSMenuFont" ref="844216569"/>
|
||||||
</object>
|
</object>
|
||||||
|
<int key="NSSelectedIndex">-1</int>
|
||||||
<bool key="NSPullDown">YES</bool>
|
<bool key="NSPullDown">YES</bool>
|
||||||
<int key="NSPreferredEdge">1</int>
|
<int key="NSPreferredEdge">1</int>
|
||||||
<bool key="NSUsesItemFromMenu">YES</bool>
|
<bool key="NSUsesItemFromMenu">YES</bool>
|
||||||
|
@ -1756,7 +1757,7 @@
|
||||||
<string key="154.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string key="154.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string key="16.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string key="16.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<reference key="161.IBNSViewMetadataGestureRecognizers" ref="0"/>
|
<reference key="161.IBNSViewMetadataGestureRecognizers" ref="0"/>
|
||||||
<string key="161.IBPersistedLastKnownCanvasPosition">{229, 364.5}</string>
|
<string key="161.IBPersistedLastKnownCanvasPosition">{84.5, 324.5}</string>
|
||||||
<string key="161.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string key="161.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string key="162.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string key="162.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string key="165.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string key="165.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1868,6 +1868,8 @@
|
||||||
|
|
||||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||||
[cdsCore setSlot1StatusText:NSSTRING_STATUS_EMULATION_NOT_RUNNING];
|
[cdsCore setSlot1StatusText:NSSTRING_STATUS_EMULATION_NOT_RUNNING];
|
||||||
|
[[cdsCore cdsController] resetMicLevel];
|
||||||
|
[[cdsCore cdsController] updateMicLevel];
|
||||||
|
|
||||||
result = YES;
|
result = YES;
|
||||||
|
|
||||||
|
@ -2111,6 +2113,11 @@
|
||||||
|
|
||||||
- (void) setupUserDefaults
|
- (void) setupUserDefaults
|
||||||
{
|
{
|
||||||
|
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||||
|
|
||||||
|
// Set the microphone settings per user preferences.
|
||||||
|
[[cdsCore cdsController] setHardwareMicMute:[[NSUserDefaults standardUserDefaults] boolForKey:@"Microphone_HardwareMicMute"]];
|
||||||
|
|
||||||
// Set the SPU settings per user preferences.
|
// Set the SPU settings per user preferences.
|
||||||
[self setCurrentVolumeValue:[[NSUserDefaults standardUserDefaults] floatForKey:@"Sound_Volume"]];
|
[self setCurrentVolumeValue:[[NSUserDefaults standardUserDefaults] floatForKey:@"Sound_Volume"]];
|
||||||
[[self cdsSpeaker] setVolume:[[NSUserDefaults standardUserDefaults] floatForKey:@"Sound_Volume"]];
|
[[self cdsSpeaker] setVolume:[[NSUserDefaults standardUserDefaults] floatForKey:@"Sound_Volume"]];
|
||||||
|
@ -2121,7 +2128,6 @@
|
||||||
[[self cdsSpeaker] setSpuSyncMethod:[[NSUserDefaults standardUserDefaults] integerForKey:@"SPU_SyncMethod"]];
|
[[self cdsSpeaker] setSpuSyncMethod:[[NSUserDefaults standardUserDefaults] integerForKey:@"SPU_SyncMethod"]];
|
||||||
|
|
||||||
// Set the 3D rendering options per user preferences.
|
// Set the 3D rendering options per user preferences.
|
||||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
|
||||||
[[cdsCore cdsGPU] setRender3DThreads:(NSUInteger)[[NSUserDefaults standardUserDefaults] integerForKey:@"Render3D_Threads"]];
|
[[cdsCore cdsGPU] setRender3DThreads:(NSUInteger)[[NSUserDefaults standardUserDefaults] integerForKey:@"Render3D_Threads"]];
|
||||||
[[cdsCore cdsGPU] setRender3DRenderingEngine:[[NSUserDefaults standardUserDefaults] integerForKey:@"Render3D_RenderingEngine"]];
|
[[cdsCore cdsGPU] setRender3DRenderingEngine:[[NSUserDefaults standardUserDefaults] integerForKey:@"Render3D_RenderingEngine"]];
|
||||||
[[cdsCore cdsGPU] setRender3DHighPrecisionColorInterpolation:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_HighPrecisionColorInterpolation"]];
|
[[cdsCore cdsGPU] setRender3DHighPrecisionColorInterpolation:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_HighPrecisionColorInterpolation"]];
|
||||||
|
@ -2422,7 +2428,7 @@
|
||||||
|
|
||||||
#pragma mark CocoaDSControllerDelegate Protocol
|
#pragma mark CocoaDSControllerDelegate Protocol
|
||||||
|
|
||||||
- (uint8_t) doMicSamplesReadFromController:(CocoaDSController *)cdsController inSample:(uint8_t)sampleValue
|
- (void) doMicLevelUpdateFromController:(CocoaDSController *)cdsController
|
||||||
{
|
{
|
||||||
BOOL needsUpdate = NO;
|
BOOL needsUpdate = NO;
|
||||||
const BOOL controllerSoftwareMicState = [cdsController softwareMicState];
|
const BOOL controllerSoftwareMicState = [cdsController softwareMicState];
|
||||||
|
@ -2463,8 +2469,6 @@
|
||||||
{
|
{
|
||||||
[self updateMicStatusIcon];
|
[self updateMicStatusIcon];
|
||||||
}
|
}
|
||||||
|
|
||||||
return sampleValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) doMicHardwareStateChangedFromController:(CocoaDSController *)cdsController
|
- (void) doMicHardwareStateChangedFromController:(CocoaDSController *)cdsController
|
||||||
|
|
|
@ -181,8 +181,9 @@
|
||||||
|
|
||||||
// Init the DS controller.
|
// Init the DS controller.
|
||||||
CocoaDSController *newController = [[[CocoaDSController alloc] init] autorelease];
|
CocoaDSController *newController = [[[CocoaDSController alloc] init] autorelease];
|
||||||
[newController setDelegate:emuControl];
|
|
||||||
[newCore setCdsController:newController];
|
[newCore setCdsController:newController];
|
||||||
|
[newController setDelegate:emuControl];
|
||||||
|
[newController setHardwareMicEnabled:YES];
|
||||||
|
|
||||||
// Init the DS speakers.
|
// Init the DS speakers.
|
||||||
CocoaDSSpeaker *newSpeaker = [[[CocoaDSSpeaker alloc] init] autorelease];
|
CocoaDSSpeaker *newSpeaker = [[[CocoaDSSpeaker alloc] init] autorelease];
|
||||||
|
@ -212,6 +213,7 @@
|
||||||
|
|
||||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
|
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||||
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
|
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
|
||||||
|
|
||||||
// Determine if the app was run for the first time.
|
// Determine if the app was run for the first time.
|
||||||
|
@ -241,6 +243,10 @@
|
||||||
[[inputPrefsView inputPrefOutlineView] expandItem:nil expandChildren:YES];
|
[[inputPrefsView inputPrefOutlineView] expandItem:nil expandChildren:YES];
|
||||||
[[inputPrefsView inputProfileMenu] selectItemAtIndex:0];
|
[[inputPrefsView inputProfileMenu] selectItemAtIndex:0];
|
||||||
|
|
||||||
|
// Make sure that the mic is paused to start with.
|
||||||
|
[[cdsCore cdsController] setHardwareMicPause:YES];
|
||||||
|
[emuControl updateMicStatusIcon];
|
||||||
|
|
||||||
//Bring the application to the front
|
//Bring the application to the front
|
||||||
[NSApp activateIgnoringOtherApps:TRUE];
|
[NSApp activateIgnoringOtherApps:TRUE];
|
||||||
[self restoreDisplayWindowStates];
|
[self restoreDisplayWindowStates];
|
||||||
|
@ -341,6 +347,7 @@
|
||||||
// Save some settings to user defaults before app termination
|
// Save some settings to user defaults before app termination
|
||||||
[self saveDisplayWindowStates];
|
[self saveDisplayWindowStates];
|
||||||
[romInfoPanel writeDefaults];
|
[romInfoPanel writeDefaults];
|
||||||
|
[[NSUserDefaults standardUserDefaults] setBool:[[cdsCore cdsController] hardwareMicMute] forKey:@"Microphone_HardwareMicMute"];
|
||||||
[[NSUserDefaults standardUserDefaults] setDouble:[emuControl lastSetSpeedScalar] forKey:@"CoreControl_SpeedScalar"];
|
[[NSUserDefaults standardUserDefaults] setDouble:[emuControl lastSetSpeedScalar] forKey:@"CoreControl_SpeedScalar"];
|
||||||
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore isSpeedLimitEnabled] forKey:@"CoreControl_EnableSpeedLimit"];
|
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore isSpeedLimitEnabled] forKey:@"CoreControl_EnableSpeedLimit"];
|
||||||
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore isFrameSkipEnabled] forKey:@"CoreControl_EnableAutoFrameSkip"];
|
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore isFrameSkipEnabled] forKey:@"CoreControl_EnableAutoFrameSkip"];
|
||||||
|
|
Loading…
Reference in New Issue