Skip to content

Commit

Permalink
updated examples for OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
syedhali committed Jul 6, 2015
1 parent 6684a87 commit 59bd612
Show file tree
Hide file tree
Showing 8 changed files with 850 additions and 381 deletions.
9 changes: 3 additions & 6 deletions EZAudio/EZOutput.m
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,11 @@ - (void)setup
[self setClientFormat:[self defaultClientFormat]];
[self setInputFormat:[self defaultInputFormat]];

#if TARGET_OS_IPHONE
//
// Use the default device
//
EZAudioDevice *currentOutputDevice = [EZAudioDevice currentOutputDevice];
[self setDevice:currentOutputDevice];
#elif TARGET_OS_MAC
NSArray *outputDevices = [EZAudioDevice outputDevices];
EZAudioDevice *defaultOutput = [outputDevices firstObject];
[self setDevice:defaultOutput];
#endif

//
// Set maximum frames per slice to 4096 to allow playback during
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5053" systemVersion="13C64" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5053"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand All @@ -10,7 +11,7 @@
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<menu title="AMainMenu" systemMenu="main" id="29">
<items>
<menuItem title="EZAudioFFTExample" id="56">
Expand Down Expand Up @@ -647,10 +648,10 @@
</items>
</menu>
<window title="EZAudioFFTExample" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="371">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" fullSizeContentView="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
<view key="contentView" id="372">
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@
/**
The OpenGL based audio plot
*/
@property (nonatomic,weak) IBOutlet EZAudioPlotGL *audioPlot;
@property (nonatomic, weak) IBOutlet EZAudioPlotGL *audioPlot;

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

/**
The label used to display the microphone state
*/
@property (nonatomic, weak) IBOutlet NSButton *microphoneSwitch;

//------------------------------------------------------------------------------
#pragma mark - Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ - (void)drawRollingPlot
#pragma mark - EZMicrophoneDelegate
//------------------------------------------------------------------------------

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

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

-(void) microphone:(EZMicrophone *)microphone
hasAudioReceived:(float **)buffer
withBufferSize:(UInt32)bufferSize
Expand All @@ -144,6 +152,19 @@ -(void) microphone:(EZMicrophone *)microphone
});
}

//------------------------------------------------------------------------------
#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
Original file line number Diff line number Diff line change
@@ -1,69 +1,89 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment version="1070" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="PassThroughViewController">
<connections>
<outlet property="audioPlot" destination="szV-uu-KbA" id="KwB-bl-yeS"/>
<outlet property="microphoneSwitch" destination="hej-uQ-uG1" id="fhN-xl-LNP"/>
<outlet property="view" destination="1d9-8y-ung" id="BT4-Db-KNk"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="1d9-8y-ung">
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="szV-uu-KbA" customClass="EZAudioPlotGL">
<rect key="frame" x="0.0" y="42" width="480" height="230"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</customView>
<button translatesAutoresizingMaskIntoConstraints="NO" id="hej-uQ-uG1">
<rect key="frame" x="18" y="14" width="119" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="fd8-mW-5iG"/>
</constraints>
<buttonCell key="cell" type="check" title="Microphone On" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="k97-dB-fHu">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="toggleMicrophone:" target="-2" id="ofz-vX-IjK"/>
</connections>
</button>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sPx-Eg-cI6">
<rect key="frame" x="333" y="11" width="129" height="24"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
<subviews>
<box autoresizesSubviews="NO" title="Box" boxType="custom" borderType="none" translatesAutoresizingMaskIntoConstraints="NO" id="eSf-nW-gda">
<rect key="frame" x="0.0" y="0.0" width="480" height="57"/>
<view key="contentView">
<rect key="frame" x="0.0" y="0.0" width="480" height="57"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button translatesAutoresizingMaskIntoConstraints="NO" id="hej-uQ-uG1">
<rect key="frame" x="16" y="16" width="119" height="18"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="fd8-mW-5iG"/>
<constraint firstAttribute="width" constant="115" id="znu-AU-bWg"/>
</constraints>
<buttonCell key="cell" type="check" title="Microphone On" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="k97-dB-fHu">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="toggleMicrophone:" target="-2" id="ofz-vX-IjK"/>
</connections>
</button>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sPx-Eg-cI6">
<rect key="frame" x="335" y="16" width="129" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="125" id="JlH-Js-Z1d"/>
<constraint firstAttribute="height" constant="21" id="hEY-sc-Ib0"/>
</constraints>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="q61-MR-tCv">
<font key="font" metaFont="system"/>
<segments>
<segment label="Buffer" selected="YES"/>
<segment label="Rolling" tag="1"/>
</segments>
</segmentedCell>
<connections>
<action selector="changePlotType:" target="-2" id="UVX-Mg-yXi"/>
</connections>
</segmentedControl>
</subviews>
</view>
<constraints>
<constraint firstAttribute="trailing" secondItem="sPx-Eg-cI6" secondAttribute="trailing" constant="18" id="3dz-EL-GYk"/>
<constraint firstItem="hej-uQ-uG1" firstAttribute="leading" secondItem="eSf-nW-gda" secondAttribute="leading" constant="18" id="QRY-A3-l3d"/>
<constraint firstItem="sPx-Eg-cI6" firstAttribute="centerY" secondItem="eSf-nW-gda" secondAttribute="centerY" id="ZiD-Mc-F6Z"/>
<constraint firstItem="sPx-Eg-cI6" firstAttribute="bottom" secondItem="hej-uQ-uG1" secondAttribute="bottom" id="kMA-Gc-Asn"/>
<constraint firstAttribute="height" constant="57" id="q54-Ma-rT2"/>
</constraints>
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
<color key="fillColor" red="0.0" green="0.0" blue="0.0" alpha="0.70000000000000007" colorSpace="calibratedRGB"/>
</box>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="21" id="hEY-sc-Ib0"/>
<constraint firstItem="eSf-nW-gda" firstAttribute="leading" secondItem="szV-uu-KbA" secondAttribute="leading" id="n5W-wG-XMz"/>
<constraint firstAttribute="bottom" secondItem="eSf-nW-gda" secondAttribute="bottom" id="ob1-us-1L5"/>
<constraint firstAttribute="trailing" secondItem="eSf-nW-gda" secondAttribute="trailing" id="pGc-Rn-8IL"/>
</constraints>
<segmentedCell key="cell" alignment="left" style="rounded" trackingMode="selectOne" id="q61-MR-tCv">
<font key="font" metaFont="system"/>
<segments>
<segment label="Buffer" selected="YES"/>
<segment label="Rolling" tag="1"/>
</segments>
</segmentedCell>
<connections>
<action selector="changePlotType:" target="-2" id="UVX-Mg-yXi"/>
</connections>
</segmentedControl>
</customView>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="szV-uu-KbA" secondAttribute="bottom" id="8NU-Oj-lK1"/>
<constraint firstAttribute="trailing" secondItem="szV-uu-KbA" secondAttribute="trailing" id="AVW-CO-N2Q"/>
<constraint firstItem="szV-uu-KbA" firstAttribute="top" secondItem="1d9-8y-ung" secondAttribute="top" id="DM4-bU-zuP"/>
<constraint firstItem="sPx-Eg-cI6" firstAttribute="top" secondItem="szV-uu-KbA" secondAttribute="bottom" constant="8" id="EFb-mI-KZS"/>
<constraint firstAttribute="trailing" secondItem="sPx-Eg-cI6" secondAttribute="trailing" constant="20" id="MiO-PO-tmm"/>
<constraint firstItem="hej-uQ-uG1" firstAttribute="leading" secondItem="1d9-8y-ung" secondAttribute="leading" constant="20" id="NJE-fd-586"/>
<constraint firstItem="szV-uu-KbA" firstAttribute="leading" secondItem="1d9-8y-ung" secondAttribute="leading" id="Qkq-oi-gx2"/>
<constraint firstAttribute="bottom" secondItem="hej-uQ-uG1" secondAttribute="bottom" constant="16" id="UXq-4r-K0N"/>
<constraint firstAttribute="bottom" secondItem="sPx-Eg-cI6" secondAttribute="bottom" constant="13" id="V0F-aH-MAE"/>
<constraint firstItem="hej-uQ-uG1" firstAttribute="top" secondItem="szV-uu-KbA" secondAttribute="bottom" constant="12" id="cPy-qk-vL2"/>
</constraints>
</customView>
</objects>
</document>
</document>
Loading

0 comments on commit 59bd612

Please sign in to comment.