开发者

Recording PCM audio in silverlight 4

开发者 https://www.devze.com 2023-03-30 15:40 出处:网络
I have encountered a strange behavior in Silverlight application and couldn\'t be able to resolve it after trying many hours.

I have encountered a strange behavior in Silverlight application and couldn't be able to resolve it after trying many hours.

  • Since I cannot access AudioFormat's internal constructor in my code (even using reflection caused silverlight security policies to raise an exception), How can I change audio format (in my class which is derived from AudioSink class. Right now, I override the method in my MemoryAudioSink class as follows:

    protected override void OnFormatChange(AudioFormat audioFormat)
    {
        if (this.audioFormat == null)
        {
            this.audioFormat = audioFormat;
        }
        else
        {
            throw new InvalidOperationException();
        }
    }  
    

    I cannot create new AudioFormat (no ctor available) and the default AudioFomat has 16000 samples per seconds which has no setter. I'd like to record and save audio, in a Mono (Channels = 1), 8 bit(Bits Per Sample = 8), 8k (Samples Per Second = 8000) format.

Also, I have used Cool Edit to record 8bit 8k audio successfully to make 开发者_如何转开发sure my sound card supports it.

So simply put, Can I record audio with my custom AudioFormat or should I record the audio in Silverlight, pass it to my WebApp, and convert it to my custom format using a third party library (which I'm not aware of any)?


This link might help you: Silverlight 4 audio recording and upload to server Sry for my stupidity I dont know how to format code, in that link I gave you, look for line AudioFormat desiredAudioFormat = null; go there, you need next foreach

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号