java - Android.Media.AudioTrack.GetMinBufferSize Method - how to use its syntax in Xamarin.Android (c#)? -


I am currently making music app for Android using csharp in XMerin Studio. I am making a simple synthesizer app and at the moment I have got caught up with a cataract with the Getminbuffer sise method.

The Xamarin.Android Documentation provides the following syntax for the GetMinBufferSize method (Here's the link:

<[Android]. [Android.Rinetime. ("Mum buffer size" "(III) I", "")] Public static interimer seiz (int sampling RATIH, [Android version.]. ChannelOut Channel Config, [Android. Animated ANUM] encoding audioformat)
  • that matches the following in Java (link :):

Public address Thir intinbufrases (int samples RATIZZ, int channel config, int audio format)

What I do not understand is things and how should I use them: [Android.Runtime.Register ("GetMinBufferSize", " (III) I "," The code was easy in Java:

  int buffsize = AudioTrack.getMinBufferSize (_sampleRate,),   aud IoFormat.CHANNEL_OUT_MONO, audio format. ENCODING_PCM_16BIT );  

Where _sampleRate int_sampleRate = 44100; and represents the frequency of the rate.

So, if you have at least told me That's the three rows in the field from the xamarin documentation - I'm so grateful.

Thank you in advance and a great day.

My code is so far:

  name space Simple_synce {activity (label = "_secondAct")} // Activity which opens the second screen public class _secondAct: Activity {Thread _ Thread; // audio processing thread int _sRate = 44100; // sampling rate boolRunning = true; // switch on / off protected override zero octet (bundle bundle) {base.OnCreate (bundle); SetContentView (Resource Layout._secondLay); Button btn2 = FindViewById & lt; Button & gt; (Resource.Id.myButton_synth); _audio _audio sound = new_audio (); Btn2.Click + = (Sender, E) = & gt; {Btn2.Text = "Good"; Thread _audioThread = new thread (_audioSound._makeSound); _audioThread.Start (); Console.witline ("audio thread: start"); While (! _audioThread.IsAlive); Thread.Sleep (1000); _audioSound._stopRequest (); _audioThread.Join (); Console.light line ("audio thread: end now!"); _audioSound._startRequest (); }; }} // _ seconds Official public class _ audio {personal volatile boulevard _stop Eaton; Public Zero _makeSound () {// This method will be called when thread will start. While (! _stopItNow) {Console.WriteLine ("Audio thread: Sound is running ..."); Audiotrack _audiettrack = new audiotrack (stream music, 22050, channel configuration. Mono, android media. Encoding. Pcm 16 bit, _audBuffer. Long, audiotrackmod.stream); _audioTrack.Play (); _audioTrack.Write (_audBuffer, 0, _audBuffer.Length); } Console. WrightLine ("Audio thread: Finish."); } // doWork Public Zero _stopRequest () {_stopItNow = true; } Public Zero _startRequest () {_stopItNow = false; Very simple in C #: 
   

var minBufSize = AudioTrack.GetMinBufferSize (44100, ChannelOut.Mono , Encoding.pm16 bit);

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -