Having trouble decoding on WP7.1

Sep 6, 2012 at 11:09 AM
Edited Sep 6, 2012 at 11:10 AM

I created a WP7.1 project and encoding works fine, but after decoding I cannot play the sound effect. I got an InvalidOperationException when creating SoundEffect instance. It seems the audio buffer is not decoded properly. Here is my reference encoding/decoding code https://gist.github.com/ogazitt

And the error happened at the red line:

// encoded byte[] encodedAudioBuffer
MemoryStream stream = new MemoryStream(encodedAudioBuffer);   
MemoryStream decodedstream = DecodeSpeexStream(stream);
se = SoundEffect.FromStream(decodedstream);
stream.Close();
currentSound = se.CreateInstance();
currentSound.Play();

Sep 14, 2012 at 9:17 PM

Hi,

I'm also working on a Windows Phone project (class library).

You're saying the encoding works fine but I can't get past a MissingMethodException (Could not load type 'System.Diagnosis.Contracts.Internal.ContractHelper' from assembly 'mscorlib, Version=3.7.0.0...')

What NSPEEX DLL are you using?

Sep 14, 2012 at 9:47 PM
Edited Sep 14, 2012 at 9:47 PM

Ok I figured it out (probably the same way you did). I replaced all the `Contract.Requires` with `if (...) throw new SomeException();`

Nov 7, 2012 at 6:42 AM

Hi,

I have the same problem with you  MissingMethodException (Could not load type 'System.Diagnosis.Contracts.Internal.ContractHelper' from assembly 'mscorlib, Version=3.7.0.0...');  you replaced all the  `Contract.Requires` with `if (...) throw new SomeException();`,

but I can't find the place where Contract is used, can you give more details? thank you.

Nov 7, 2012 at 12:01 PM

oh, I have found it in source code.  encode and decode  all work.  But what i compressed can't play on my computer in foobar2000, I download a speex file,but it can play in foobar2000.

what's wrong?