Recording PCM audio in silverlight 4

允我心安 提交于 2019-12-11 06:17:54

问题


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)?


回答1:


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



来源:https://stackoverflow.com/questions/7175217/recording-pcm-audio-in-silverlight-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!