≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Can recorder.RecordedAudioData be accessed from memory?
Posted by:
(you are not logged in)
Enter the missing letter in: "?nternational"
(you are not logged in)
Text:
[quote][b][/b] wrote: Sure. CASE 1 - record sound, playback sound, directly from memory: (the 'etc.' stands for unrelated stuff) (loop_flag is set to 'false') public partial class playrecSoundWin : Window { static string rec_sound0 = "recording0"; public static ISoundEngine engine0; public static IAudioRecorder recorder0; etc. public playrecSoundWin() { InitializeComponent(); engine0 = new ISoundEngine(); recorder0 = new IAudioRecorder(engine0); etc. private void startRecBtn_Click(object sender, RoutedEventArgs e) { engine0.RemoveAllSoundSources(); //otherwise no further recording takes place recorder0.StartRecordingBufferedAudio(); } private void stopRecBtn_Click(object sender, RoutedEventArgs e) { if (recorder0 != null) { recorder0.StopRecordingAudio(); } } private void startPlayBtn_Click(object sender, RoutedEventArgs e) { recorder0.AddSoundSourceFromRecordedAudio(rec_sound0); engine0.Play2D(rec_sound0, loop_flag); } No problem, can be repeated over and over. CASE 2 - record sound, copy sound to array, playback sound: public partial class playrecSoundWin : Window { static string rec_sound0 = "recording0"; static string rec_sound1 = "recording1"; public static ISoundEngine engine0, engine1; public static ISound sound1; public static ISoundSource soundsource1; public static IAudioRecorder recorder0; public playrecSoundWin() { InitializeComponent(); engine0 = new ISoundEngine(); //Note: cannot do this for engine1 here! recorder0 = new IAudioRecorder(engine0); etc. Start and Stop recording is the same as CASE 1, and then: private void startPlayBtn_Click(object sender, RoutedEventArgs e) { recorder0.AddSoundSourceFromRecordedAudio(rec_sound0); af = recorder0.AudioFormat; SoundDataArray1 = new byte[recorder0.RecordedAudioData.Length]; Array.Copy(recorder0.RecordedAudioData, SoundDataArray1, recorder0.RecordedAudioData.Length); engine1 = new ISoundEngine(); //Note: now engine1 must be declared soundsource1 = engine1.AddSoundSourceFromPCMData(SoundDataArray1, rec_sound1, af); sound1 = engine1.Play2D(soundsource1, loop_flag, false, false); } Then sound1 can be used for changing volume, speed, checking whether it is finished, etc etc, and the entire operation can be repeated many times. However, had I defined engine1 as in CASE 1 there is no sound1, it never gets instantiated. I also tested this case in a loop where the whole recording and playback is called over and over again, and according to TaskManager > Performance there is no notable memory use increase, so the disposal of engine1 etc must be quite efficient nevertheless. Still, what is the underlying difference between CASE 1 and 2? Thanks for all your time![/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact