You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2013/02/20 23:20:30 UTC
[15/26] wp7 commit: merge, cleanup
merge, cleanup
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp7/commit/11cf6142
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp7/tree/11cf6142
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp7/diff/11cf6142
Branch: refs/heads/master
Commit: 11cf6142ebc7d503b20dbce8c74259c4528aec64
Parents: b3c7b81 59c3e55
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Feb 19 11:32:34 2013 -0800
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Feb 19 11:32:34 2013 -0800
----------------------------------------------------------------------
README.md | 2 +-
templates/full/www/css/index.css | 2 +-
templates/full/www/js/index.js | 2 +-
.../standalone/cordovalib/Commands/AudioPlayer.cs | 1 +
.../standalone/cordovalib/Commands/Contacts.cs | 4 +-
templates/standalone/cordovalib/Commands/File.cs | 2 +-
.../cordovalib/Commands/ImageExifHelper.cs | 4 +-
.../standalone/cordovalib/Commands/Notification.cs | 38 +++++++-------
.../standalone/cordovalib/CordovaView.xaml.cs | 2 +-
.../standalone/cordovalib/UI/AudioRecorder.xaml.cs | 1 -
templates/standalone/www/css/index.css | 2 +-
templates/standalone/www/js/index.js | 2 +-
12 files changed, 31 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/11cf6142/templates/standalone/cordovalib/Commands/AudioPlayer.cs
----------------------------------------------------------------------
diff --cc templates/standalone/cordovalib/Commands/AudioPlayer.cs
index 77c6f8a,71f3849..ffc6a94
--- a/templates/standalone/cordovalib/Commands/AudioPlayer.cs
+++ b/templates/standalone/cordovalib/Commands/AudioPlayer.cs
@@@ -521,8 -513,89 +521,9 @@@ namespace WPCordovaClassLib.Cordova.Com
//TODO: log or do something else
throw;
}
- }
-
-
-
- #region Wav format
- // Original source http://damianblog.com/2011/02/07/storing-wp7-recorded-audio-as-wav-format-streams/
-
- /// <summary>
- /// Adds wav file format header to the stream
- /// https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
- /// </summary>
- /// <param name="stream">Wav stream</param>
- /// <param name="sampleRate">Sample Rate</param>
- private void WriteWavHeader(Stream stream, int sampleRate)
- {
- const int bitsPerSample = 16;
- const int bytesPerSample = bitsPerSample / 8;
- var encoding = System.Text.Encoding.UTF8;
-
- // ChunkID Contains the letters "RIFF" in ASCII form (0x52494646 big-endian form).
- stream.Write(encoding.GetBytes("RIFF"), 0, 4);
-
- // NOTE this will be filled in later
- stream.Write(BitConverter.GetBytes(0), 0, 4);
-
- // Format Contains the letters "WAVE"(0x57415645 big-endian form).
- stream.Write(encoding.GetBytes("WAVE"), 0, 4);
-
- // Subchunk1ID Contains the letters "fmt " (0x666d7420 big-endian form).
- stream.Write(encoding.GetBytes("fmt "), 0, 4);
+ }
- // Subchunk1Size 16 for PCM. This is the size of the rest of the Subchunk which follows this number.
- stream.Write(BitConverter.GetBytes(16), 0, 4);
-
- // AudioFormat PCM = 1 (i.e. Linear quantization) Values other than 1 indicate some form of compression.
- stream.Write(BitConverter.GetBytes((short)1), 0, 2);
-
- // NumChannels Mono = 1, Stereo = 2, etc.
- stream.Write(BitConverter.GetBytes((short)1), 0, 2);
-
- // SampleRate 8000, 44100, etc.
- stream.Write(BitConverter.GetBytes(sampleRate), 0, 4);
-
- // ByteRate = SampleRate * NumChannels * BitsPerSample/8
- stream.Write(BitConverter.GetBytes(sampleRate * bytesPerSample), 0, 4);
-
- // BlockAlign NumChannels * BitsPerSample/8 The number of bytes for one sample including all channels.
- stream.Write(BitConverter.GetBytes((short)(bytesPerSample)), 0, 2);
-
- // BitsPerSample 8 bits = 8, 16 bits = 16, etc.
- stream.Write(BitConverter.GetBytes((short)(bitsPerSample)), 0, 2);
-
- // Subchunk2ID Contains the letters "data" (0x64617461 big-endian form).
- stream.Write(encoding.GetBytes("data"), 0, 4);
-
- // NOTE to be filled in later
- stream.Write(BitConverter.GetBytes(0), 0, 4);
- }
-
- /// <summary>
- /// Updates wav file format header
- /// https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
- /// </summary>
- /// <param name="stream">Wav stream</param>
- private void UpdateWavHeader(Stream stream)
- {
- if (!stream.CanSeek) throw new Exception("Can't seek stream to update wav header");
-
- var oldPos = stream.Position;
-
- // ChunkSize 36 + SubChunk2Size
- stream.Seek(4, SeekOrigin.Begin);
- stream.Write(BitConverter.GetBytes((int)stream.Length - 8), 0, 4);
-
- // Subchunk2Size == NumSamples * NumChannels * BitsPerSample/8 This is the number of bytes in the data.
- stream.Seek(40, SeekOrigin.Begin);
- stream.Write(BitConverter.GetBytes((int)stream.Length - 44), 0, 4);
-
- stream.Seek(oldPos, SeekOrigin.Begin);
- }
-
- #endregion
+
#region Xna loop
/// <summary>
/// Special initialization required for the microphone: XNA game loop
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/11cf6142/templates/standalone/cordovalib/Commands/Contacts.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/11cf6142/templates/standalone/cordovalib/Commands/File.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/11cf6142/templates/standalone/cordovalib/Commands/ImageExifHelper.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/11cf6142/templates/standalone/cordovalib/Commands/Notification.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/11cf6142/templates/standalone/cordovalib/CordovaView.xaml.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/11cf6142/templates/standalone/cordovalib/UI/AudioRecorder.xaml.cs
----------------------------------------------------------------------
diff --cc templates/standalone/cordovalib/UI/AudioRecorder.xaml.cs
index 01a0832,f6c7357..bc8ba6f
--- a/templates/standalone/cordovalib/UI/AudioRecorder.xaml.cs
+++ b/templates/standalone/cordovalib/UI/AudioRecorder.xaml.cs
@@@ -302,6 -301,87 +302,5 @@@ namespace WPCordovaClassLib.Cordova.U
dtXna = null;
}
}
--
-
- #region Wav format
- // Original source http://damianblog.com/2011/02/07/storing-wp7-recorded-audio-as-wav-format-streams/
-
- /// <summary>
- /// Adds wav file format header to the stream
- /// https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
- /// </summary>
- /// <param name="stream">Wav stream</param>
- /// <param name="sampleRate">Sample Rate</param>
- private void WriteWavHeader(Stream stream, int sampleRate)
- {
- const int bitsPerSample = 16;
- const int bytesPerSample = bitsPerSample / 8;
- var encoding = System.Text.Encoding.UTF8;
-
- // ChunkID Contains the letters "RIFF" in ASCII form (0x52494646 big-endian form).
- stream.Write(encoding.GetBytes("RIFF"), 0, 4);
-
- // NOTE this will be filled in later
- stream.Write(BitConverter.GetBytes(0), 0, 4);
-
- // Format Contains the letters "WAVE"(0x57415645 big-endian form).
- stream.Write(encoding.GetBytes("WAVE"), 0, 4);
-
- // Subchunk1ID Contains the letters "fmt " (0x666d7420 big-endian form).
- stream.Write(encoding.GetBytes("fmt "), 0, 4);
-
- // Subchunk1Size 16 for PCM. This is the size of the rest of the Subchunk which follows this number.
- stream.Write(BitConverter.GetBytes(16), 0, 4);
-
- // AudioFormat PCM = 1 (i.e. Linear quantization) Values other than 1 indicate some form of compression.
- stream.Write(BitConverter.GetBytes((short)1), 0, 2);
-
- // NumChannels Mono = 1, Stereo = 2, etc.
- stream.Write(BitConverter.GetBytes((short)1), 0, 2);
-
- // SampleRate 8000, 44100, etc.
- stream.Write(BitConverter.GetBytes(sampleRate), 0, 4);
-
- // ByteRate = SampleRate * NumChannels * BitsPerSample/8
- stream.Write(BitConverter.GetBytes(sampleRate * bytesPerSample), 0, 4);
-
- // BlockAlign NumChannels * BitsPerSample/8 The number of bytes for one sample including all channels.
- stream.Write(BitConverter.GetBytes((short)(bytesPerSample)), 0, 2);
-
- // BitsPerSample 8 bits = 8, 16 bits = 16, etc.
- stream.Write(BitConverter.GetBytes((short)(bitsPerSample)), 0, 2);
-
- // Subchunk2ID Contains the letters "data" (0x64617461 big-endian form).
- stream.Write(encoding.GetBytes("data"), 0, 4);
-
- // NOTE to be filled in later
- stream.Write(BitConverter.GetBytes(0), 0, 4);
- }
-
- /// <summary>
- /// Updates wav file format header
- /// https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
- /// </summary>
- /// <param name="stream">Wav stream</param>
- private void UpdateWavHeader(Stream stream)
- {
- if (!stream.CanSeek) throw new Exception("Can't seek stream to update wav header");
-
- var oldPos = stream.Position;
-
- // ChunkSize 36 + SubChunk2Size
- stream.Seek(4, SeekOrigin.Begin);
- stream.Write(BitConverter.GetBytes((int)stream.Length - 8), 0, 4);
-
- // Subchunk2Size == NumSamples * NumChannels * BitsPerSample/8 This is the number of bytes in the data.
- stream.Seek(40, SeekOrigin.Begin);
- stream.Write(BitConverter.GetBytes((int)stream.Length - 44), 0, 4);
-
- stream.Seek(oldPos, SeekOrigin.Begin);
- }
-
- #endregion
-
-
}
}