Skip to content

Commit

Permalink
MicMonitoring sample code has a signal level label.
Browse files Browse the repository at this point in the history
  • Loading branch information
reinforce-lab committed Nov 16, 2010
1 parent cef540a commit 595ee46
Show file tree
Hide file tree
Showing 13 changed files with 200 additions and 46 deletions.
3 changes: 2 additions & 1 deletion MonoTouch_AudioUnit/AudioUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static int renderCallback(IntPtr inRefCon,
uint _inNumberFrames,
AudioBufferList _ioData)
{
//System.Diagnostics.Debug.WriteLine(_ioActionFlags);
// getting audiounit instance
var handler = GCHandle.FromIntPtr(inRefCon);
var inst = (AudioUnit)handler.Target;
Expand Down Expand Up @@ -190,7 +191,7 @@ public void Stop()
}
public void Render(AudioUnitRenderActionFlags flags, AudioTimeStamp timeStamp, UInt32 outputBusnumber, UInt32 numberFrames, AudioBufferList data)
{
int err = AudioUnitRender(_audioUnit,
int err = AudioUnitRender (_audioUnit,
ref flags,
ref timeStamp,
outputBusnumber,
Expand Down
3 changes: 2 additions & 1 deletion MonoTouch_AudioUnit/AudioUnitUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public static class AudioUnitUtils
public static AudioStreamBasicDescription AUCanonicalASBD(double sampleRate, int channel)
{
// setting AudioStreamBasicDescription
int AudioUnitSampleTypeSize = (MonoTouch.ObjCRuntime.Runtime.Arch == MonoTouch.ObjCRuntime.Arch.SIMULATOR) ? sizeof(float) : sizeof(int);
//int AudioUnitSampleTypeSize = (MonoTouch.ObjCRuntime.Runtime.Arch == MonoTouch.ObjCRuntime.Arch.SIMULATOR) ? sizeof(float) : sizeof(int);
int AudioUnitSampleTypeSize = 4;
AudioStreamBasicDescription audioFormat = new AudioStreamBasicDescription()
{
SampleRate = sampleRate,
Expand Down
20 changes: 20 additions & 0 deletions MonoTouch_AudioUnit/MonoTouch.AudioUnit_vs.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoTouch.AudioUnit_vs", "MonoTouch.AudioUnit_vs.csproj", "{195329E1-A506-43D1-9FBC-2FD604343057}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{195329E1-A506-43D1-9FBC-2FD604343057}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{195329E1-A506-43D1-9FBC-2FD604343057}.Debug|Any CPU.Build.0 = Debug|Any CPU
{195329E1-A506-43D1-9FBC-2FD604343057}.Release|Any CPU.ActiveCfg = Release|Any CPU
{195329E1-A506-43D1-9FBC-2FD604343057}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
22 changes: 11 additions & 11 deletions MonoTouch_AudioUnit_MicMonitoring/Info.plist
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.reinforce-lab.monotouch_recording</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
</dict>
</plist>
<dict>
<key>CFBundleIdentifier</key>
<string>com.reinforce-lab.monotouch_recording</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
</dict>
</plist>
80 changes: 73 additions & 7 deletions MonoTouch_AudioUnit_MicMonitoring/MainView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">768</int>
<string key="IBDocument.SystemVersion">10F569</string>
<string key="IBDocument.InterfaceBuilderVersion">788</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.SystemVersion">10H574</string>
<string key="IBDocument.InterfaceBuilderVersion">823</string>
<string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">117</string>
<string key="NS.object.0">132</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -92,6 +92,41 @@
<reference key="IBUINormalTitleColor" ref="1072140778"/>
<reference key="IBUINormalTitleShadowColor" ref="74601740"/>
</object>
<object class="IBUILabel" id="934523613">
<reference key="NSNextResponder" ref="388776789"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{39, 280}, {96, 21}}</string>
<reference key="NSSuperview" ref="388776789"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">Signal level:</string>
<object class="NSColor" key="IBUITextColor" id="788541663">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MCAwIDAAA</bytes>
</object>
<reference key="IBUIHighlightedColor" ref="634394252"/>
<int key="IBUIBaselineAdjustment">1</int>
<float key="IBUIMinimumFontSize">10</float>
</object>
<object class="IBUILabel" id="693256378">
<reference key="NSNextResponder" ref="388776789"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{153, 280}, {137, 21}}</string>
<reference key="NSSuperview" ref="388776789"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">0000</string>
<reference key="IBUITextColor" ref="788541663"/>
<reference key="IBUIHighlightedColor" ref="634394252"/>
<int key="IBUIBaselineAdjustment">1</int>
<float key="IBUIMinimumFontSize">10</float>
</object>
</object>
<string key="NSFrameSize">{320, 460}</string>
<reference key="NSSuperview" ref="191373211"/>
Expand Down Expand Up @@ -138,6 +173,14 @@
</object>
<int key="connectionID">11</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">_label</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="693256378"/>
</object>
<int key="connectionID">15</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -175,6 +218,8 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="45352830"/>
<reference ref="455241256"/>
<reference ref="934523613"/>
<reference ref="693256378"/>
</object>
<reference key="parent" ref="191373211"/>
</object>
Expand All @@ -188,6 +233,16 @@
<reference key="object" ref="455241256"/>
<reference key="parent" ref="388776789"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">13</int>
<reference key="object" ref="934523613"/>
<reference key="parent" ref="388776789"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">14</int>
<reference key="object" ref="693256378"/>
<reference key="parent" ref="388776789"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
Expand All @@ -199,14 +254,18 @@
<string>1.IBEditorWindowLastContentRect</string>
<string>1.IBPluginDependency</string>
<string>12.IBPluginDependency</string>
<string>13.IBPluginDependency</string>
<string>14.IBPluginDependency</string>
<string>8.IBPluginDependency</string>
<string>9.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>MainView</string>
<string>UIResponder</string>
<string>{{473, 512}, {320, 480}}</string>
<string>{{933, 676}, {320, 480}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
Expand All @@ -229,7 +288,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">12</int>
<int key="maxID">15</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand All @@ -240,6 +299,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>_label</string>
<string>_playButton</string>
<string>_stopButton</string>
<string>view</string>
Expand All @@ -249,18 +309,24 @@
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>_label</string>
<string>_playButton</string>
<string>_stopButton</string>
<string>view</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">_label</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">_playButton</string>
<string key="candidateClassName">id</string>
Expand Down Expand Up @@ -295,6 +361,6 @@
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<nil key="IBDocument.LastKnownRelativeProjectPath"/>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">117</string>
<string key="IBCocoaTouchPluginVersion">132</string>
</data>
</archive>
9 changes: 9 additions & 0 deletions MonoTouch_AudioUnit_MicMonitoring/MainView.xib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public partial class MainView : UIViewController
{
#region Variables
RemoteOutput _player;
NSTimer _timer;
#endregion

#region Constructors
Expand Down Expand Up @@ -59,6 +60,14 @@ public override void ViewDidLoad()

_playButton.Enabled = true;
_stopButton.Enabled = false;

_timer = NSTimer.CreateRepeatingTimer(TimeSpan.FromMilliseconds(200),
delegate
{
_label.Text = _player.SignalLevel.ToString("E");
}
);
NSRunLoop.Current.AddTimer(_timer, "NSDefaultRunLoopMode");
}
public override void ViewDidUnload()
{
Expand Down
14 changes: 14 additions & 0 deletions MonoTouch_AudioUnit_MicMonitoring/MainView.xib.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<MtouchLink>None</MtouchLink>
<MtouchI18n />
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<MtouchSdkVersion>4.0</MtouchSdkVersion>
<MtouchMinimumOS>3.1.3</MtouchMinimumOS>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|iPhone" ctype="Workspace" />
<MonoDevelop.Ide.Workbench ActiveDocument="../MonoTouch_AudioUnit/AudioUnit.cs" ctype="Workbench">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|iPhoneSimulator" />
<MonoDevelop.Ide.Workbench ActiveDocument="../MonoTouch_AudioUnit/AudioUnit.cs">
<Files>
<File FileName="../MonoTouch_AudioUnit/AudioUnit.cs" Line="179" Column="21" />
<File FileName="../MonoTouch_AudioUnit/AudioUnit.cs" Line="181" Column="14" />
<File FileName="RemoteOutput.cs" Line="104" Column="38" />
<File FileName="MainView.xib.cs" Line="13" Column="1" />
<File FileName="MainView.xib.designer.cs" Line="1" Column="1" />
</Files>
<Pads>
<Pad Id="ProjectPad">
Expand Down Expand Up @@ -30,7 +33,7 @@
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches ctype="PinnedWatchStore">
<MonoDevelop.Ide.DebuggingService.PinnedWatches>
<Watch file="../MonoTouch_AudioUnit_PlayingSinWaveform/RemoteOutput.cs" line="124" offsetX="597" offsetY="1845" expression="ostype_val" liveUpdate="False" />
</MonoDevelop.Ide.DebuggingService.PinnedWatches>
</Properties>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -12,6 +12,11 @@
<AssemblyName>Monotouch_AudioUnit_PlayingSinWaveform</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C# Express 2008
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoTouch.AudioUnit_vs", "..\MonoTouch_AudioUnit\MonoTouch.AudioUnit_vs.csproj", "{195329E1-A506-43D1-9FBC-2FD604343057}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monotouch_AudioUnit_MicMonitoring_vs", "Monotouch_AudioUnit_MicMonitoring_vs.csproj", "{4B2E61C6-9E77-4215-A307-3BB9BE755041}"
Expand Down
Loading

0 comments on commit 595ee46

Please sign in to comment.