How to get live/continious audio stream from mobile microphone

is it possible to get live audio stream from mobile mic with specified PCM format, so that I can use that stream in a socket connection.

Best Answer

  • RogerHardimanRogerHardiman GB ✭✭
    Accepted Answer

    There is nothing in Xamarin Forms which will help you - Xamarin Forms is a graphical user interface.

    You need to write custom code to use the sound APIs on each target operating system.
    Xamarin's iOS wrapper and Xamarin's Android wrapper both give you access in C# to the iOS and Android audio APIs where you can detect what audio hardware there is and initialise the microphone.

    The two APIs are very different but both will give you raw PCM in stereo or mono with the usual sample rates (8k, 16k, 32k 44.1 and 48k) and 8 or 16 bit samples

Answers

  • RogerHardimanRogerHardiman GBMember ✭✭
    Accepted Answer

    There is nothing in Xamarin Forms which will help you - Xamarin Forms is a graphical user interface.

    You need to write custom code to use the sound APIs on each target operating system.
    Xamarin's iOS wrapper and Xamarin's Android wrapper both give you access in C# to the iOS and Android audio APIs where you can detect what audio hardware there is and initialise the microphone.

    The two APIs are very different but both will give you raw PCM in stereo or mono with the usual sample rates (8k, 16k, 32k 44.1 and 48k) and 8 or 16 bit samples

  • simanchalsimanchal Member ✭✭

    Hi Roger, thank you so much for the effort. But I am completely new to Xamarin forms, can you please specify the API/library/nuget package available to achieve this functionality? Like what we have NAudio library to work with Audio functionality in web/windows using c#, is there any same kind of library for mobile app platform?

  • igigiberiaigigiberia Member ✭✭

    I have nearly same issue,

    Yet I could only approach to use recorder to get period of time recorded and analyze it after, but as I want to simplify process, I'd like to prevent process as soon as I have reason to (for e.g. too much loud around)

    I want to get live stream from microphone and analyze stream in live

    It'll be nice to initialize listener by platform specific method, called from shared code, and get the stream into shared code for further analyzes, or if it's not possible at all (that I doubt and that's why I ask) I would analyze it in platform specific method locally and give result to shared code.

    How would you suggest to listen to live stream for analyzing noise level?

Sign In or Register to comment.