Skip to content

Commit

Permalink
Merge pull request #183 from syedhali/update_examples
Browse files Browse the repository at this point in the history
Updated examples
  • Loading branch information
syedhali committed Jul 6, 2015
2 parents 5920e7a + 3bb1b91 commit 445e2fa
Show file tree
Hide file tree
Showing 16 changed files with 126 additions and 7 deletions.
5 changes: 4 additions & 1 deletion EZAudio/EZAudioPlot.h
Expand Up @@ -156,7 +156,10 @@ FOUNDATION_EXPORT UInt32 const EZAudioPlotDefaultMaxHistoryBufferLength;

//------------------------------------------------------------------------------

- (void)initPlot;
/**
Called after the view has been created. Subclasses should use to add any additional methods needed instead of overriding the init methods.
*/
- (void)setupPlot;

//------------------------------------------------------------------------------

Expand Down
14 changes: 14 additions & 0 deletions EZAudio/EZAudioPlot.m
Expand Up @@ -151,11 +151,25 @@ - (void)initPlot
self.backgroundColor = nil;
[self.layer insertSublayer:self.waveformLayer atIndex:0];

//
// Allow subclass to initialize plot
//
[self setupPlot];

self.points = calloc(EZAudioPlotDefaultMaxHistoryBufferLength, sizeof(CGPoint));
self.pointCount = [self initialPointCount];
[self redraw];
}

//------------------------------------------------------------------------------

- (void)setupPlot
{
//
// Override in subclass
//
}

//------------------------------------------------------------------------------
#pragma mark - Setup
//------------------------------------------------------------------------------
Expand Down
22 changes: 22 additions & 0 deletions EZAudio/EZAudioPlotGL.h
Expand Up @@ -206,6 +206,28 @@ typedef struct

//------------------------------------------------------------------------------

/**
Called during the OpenGL run loop to constantly update the drawing 60 fps. Callers can use this force update the screen while subclasses can override this for complete control over their rendering. However, subclasses are more encouraged to use the `redrawWithPoints:pointCount:baseEffect:vertexBufferObject:vertexArrayBuffer:interpolated:mirrored:gain:`
*/
- (void)redraw;

//------------------------------------------------------------------------------

/**
Called after the view has been created. Subclasses should use to add any additional methods needed instead of overriding the init methods.
*/
- (void)setup;

//------------------------------------------------------------------------------

/**
Main method used to copy the sample data from the source buffer and update the
plot. Subclasses can overwrite this method for custom behavior.
@param data A float array of the sample data. Subclasses should copy this data to a separate array to avoid threading issues.
@param length The length of the float array as an int.
*/
- (void)setSampleData:(float *)data length:(int)length;

///-----------------------------------------------------------
/// @name Subclass Methods
///-----------------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions EZAudio/EZAudioPlotGL.m
Expand Up @@ -182,6 +182,11 @@ - (void)setup
self.color = [NSColor colorWithCalibratedRed:1.0f green:1.0f blue:1.0f alpha:1.0f];
#endif

//
// Allow subclass to initialize plot
//
[self setupPlot];

//
// Create the display link
//
Expand All @@ -191,6 +196,15 @@ - (void)setup

//------------------------------------------------------------------------------

- (void)setupPlot
{
//
// Override in subclass
//
}

//------------------------------------------------------------------------------

- (void)setupOpenGL
{
self.baseEffect = [[GLKBaseEffect alloc] init];
Expand Down Expand Up @@ -247,6 +261,7 @@ - (void)setupOpenGL
#if !TARGET_OS_IPHONE
[self.openGLContext unlock];
#endif
self.frame = self.frame;
}

//------------------------------------------------------------------------------
Expand Down
Expand Up @@ -57,6 +57,11 @@
*/
@property (nonatomic, weak) IBOutlet NSPopUpButton *microphoneInputChannelPopUpButton;

/**
The checkbox button used to turn the microphone off/on
*/
@property (nonatomic, weak) IBOutlet NSButton *microphoneSwitch;

//------------------------------------------------------------------------------
#pragma mark - Actions
//------------------------------------------------------------------------------
Expand Down
Expand Up @@ -240,4 +240,25 @@ - (void)microphone:(EZMicrophone *)microphone

//------------------------------------------------------------------------------

- (void)microphone:(EZMicrophone *)microphone changedPlayingState:(BOOL)isPlaying
{
NSString *title = isPlaying ? @"Microphone On" : @"Microphone Off";
[self setTitle:title forButton:self.microphoneSwitch];
}

//------------------------------------------------------------------------------
#pragma mark - Utility
//------------------------------------------------------------------------------

- (void)setTitle:(NSString *)title forButton:(NSButton *)button
{
NSDictionary *attributes = @{ NSForegroundColorAttributeName : [NSColor whiteColor] };
NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:title
attributes:attributes];
button.attributedTitle = attributedTitle;
button.attributedAlternateTitle = attributedTitle;
}

//------------------------------------------------------------------------------

@end
Expand Up @@ -10,6 +10,7 @@
<outlet property="audioPlot" destination="wpL-Ou-GSb" id="OME-Hf-I27"/>
<outlet property="microphoneInputChannelPopUpButton" destination="Yi6-fS-Cob" id="pLg-4c-klV"/>
<outlet property="microphoneInputPopUpButton" destination="SjR-qx-mWV" id="NuN-SS-ESg"/>
<outlet property="microphoneSwitch" destination="kAI-gs-c31" id="ADZ-Fg-aCN"/>
<outlet property="view" destination="wpL-Ou-GSb" id="oxJ-iT-SKO"/>
</connections>
</customObject>
Expand Down Expand Up @@ -83,15 +84,15 @@
<rect key="frame" x="18" y="43" width="36" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Input" id="Png-Pk-fMc">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="HVN-Im-3J1">
<rect key="frame" x="204" y="43" width="55" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Channel" id="lkh-zp-WCY">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
Expand Down
Expand Up @@ -61,6 +61,11 @@
*/
@property (nonatomic, weak) IBOutlet NSPopUpButton *microphoneInputChannelPopUpButton;

/**
The checkbox button used to turn the microphone off/on
*/
@property (nonatomic, weak) IBOutlet NSButton *microphoneSwitch;

//------------------------------------------------------------------------------
#pragma mark - Actions
//------------------------------------------------------------------------------
Expand Down
Expand Up @@ -226,8 +226,7 @@ - (void)microphone:(EZMicrophone *)microphone

//------------------------------------------------------------------------------

- (void)microphone:(EZMicrophone *)microphone
changedDevice:(EZAudioDevice *)device
- (void)microphone:(EZMicrophone *)microphone changedDevice:(EZAudioDevice *)device
{
dispatch_async(dispatch_get_main_queue(), ^{
//
Expand All @@ -246,4 +245,25 @@ - (void)microphone:(EZMicrophone *)microphone

//------------------------------------------------------------------------------

- (void)microphone:(EZMicrophone *)microphone changedPlayingState:(BOOL)isPlaying
{
NSString *title = isPlaying ? @"Microphone On" : @"Microphone Off";
[self setTitle:title forButton:self.microphoneSwitch];
}

//------------------------------------------------------------------------------
#pragma mark - Utility
//------------------------------------------------------------------------------

- (void)setTitle:(NSString *)title forButton:(NSButton *)button
{
NSDictionary *attributes = @{ NSForegroundColorAttributeName : [NSColor whiteColor] };
NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:title
attributes:attributes];
button.attributedTitle = attributedTitle;
button.attributedAlternateTitle = attributedTitle;
}

//------------------------------------------------------------------------------

@end
Expand Up @@ -10,6 +10,7 @@
<outlet property="audioPlot" destination="foT-nv-032" id="Baw-Le-z98"/>
<outlet property="microphoneInputChannelPopUpButton" destination="Usd-lp-n8s" id="FbQ-hj-24k"/>
<outlet property="microphoneInputPopUpButton" destination="wBG-jf-wVy" id="thS-Ur-IMj"/>
<outlet property="microphoneSwitch" destination="TbW-ha-PgJ" id="wEZ-dt-f7t"/>
<outlet property="view" destination="hFn-jA-9Se" id="cfu-I4-qhQ"/>
</connections>
</customObject>
Expand Down Expand Up @@ -86,15 +87,15 @@
<rect key="frame" x="18" y="46" width="36" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Input" id="Fq3-tX-8aU">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="PMV-Zt-Wg6">
<rect key="frame" x="204" y="46" width="55" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Channel" id="PTE-g2-mTV">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
Expand Down
Expand Up @@ -506,6 +506,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "EZAudioFFTExample/EZAudioFFTExample-Prefix.pch";
INFOPLIST_FILE = "EZAudioFFTExample/EZAudioFFTExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -519,6 +520,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "EZAudioFFTExample/EZAudioFFTExample-Prefix.pch";
INFOPLIST_FILE = "EZAudioFFTExample/EZAudioFFTExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down
Expand Up @@ -502,6 +502,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "EZAudioOpenGLWaveformExample/EZAudioOpenGLWaveformExample-Prefix.pch";
INFOPLIST_FILE = "EZAudioOpenGLWaveformExample/EZAudioOpenGLWaveformExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -515,6 +516,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "EZAudioOpenGLWaveformExample/EZAudioOpenGLWaveformExample-Prefix.pch";
INFOPLIST_FILE = "EZAudioOpenGLWaveformExample/EZAudioOpenGLWaveformExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down
Expand Up @@ -502,6 +502,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "EZAudioPassThroughExample/EZAudioPassThroughExample-Prefix.pch";
INFOPLIST_FILE = "EZAudioPassThroughExample/EZAudioPassThroughExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -515,6 +516,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "EZAudioPassThroughExample/EZAudioPassThroughExample-Prefix.pch";
INFOPLIST_FILE = "EZAudioPassThroughExample/EZAudioPassThroughExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down
Expand Up @@ -506,6 +506,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "EZAudioPlayFileExample/EZAudioPlayFileExample-Prefix.pch";
INFOPLIST_FILE = "EZAudioPlayFileExample/EZAudioPlayFileExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -519,6 +520,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "EZAudioPlayFileExample/EZAudioPlayFileExample-Prefix.pch";
INFOPLIST_FILE = "EZAudioPlayFileExample/EZAudioPlayFileExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down
Expand Up @@ -502,6 +502,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "EZAudioRecordExample/EZAudioRecordExample-Prefix.pch";
INFOPLIST_FILE = "EZAudioRecordExample/EZAudioRecordExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -515,6 +516,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "EZAudioRecordExample/EZAudioRecordExample-Prefix.pch";
INFOPLIST_FILE = "EZAudioRecordExample/EZAudioRecordExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down
Expand Up @@ -506,6 +506,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "EZAudioWaveformFromFileExample/EZAudioWaveformFromFileExample-Prefix.pch";
INFOPLIST_FILE = "EZAudioWaveformFromFileExample/EZAudioWaveformFromFileExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -519,6 +520,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "EZAudioWaveformFromFileExample/EZAudioWaveformFromFileExample-Prefix.pch";
INFOPLIST_FILE = "EZAudioWaveformFromFileExample/EZAudioWaveformFromFileExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down

0 comments on commit 445e2fa

Please sign in to comment.