title: Android.Media.AudioTrack.GetMinBufferSize Method - how to use its syntax in Xamarin.Android (c#)?
body: <p>I am currently making a music app for Android in Xamarin studio using csharp. I am making a simple synthesizer app and at the moment I am stuck with GetMinBufferSize method with csharp.</p>
  
  <p>Xamarin.Android documentation provides the following syntax for the GetMinBufferSize method (here's the link: <a href="http://androidapi.xamarin.com/index.aspx?link=M%3aAndroid.Media.AudioTrack.GetMinBufferSize%28System.Int32,Android.Media.ChannelOut,Android.Media.Encoding%29" rel="nofollow">xamarin API audiotrack documentation</a>:</p>
  
  <pre><code>[Android.Runtime.Register("getMinBufferSize", "(III)I", "")]
  public static int GetMinBufferSize (int sampleRateInHz, 
  [Android.Runtime.GeneratedEnum] ChannelOut channelConfig, 
  [Android.Runtime.GeneratedEnum] Encoding audioFormat)
  </code></pre>
  
  <ul>
  <li>which corresponds to the following in Java (link: <a href="http://developer.android.com/reference/android/media/AudioTrack.html#getMinBufferSize%28int,%20int,%20int%29" rel="nofollow">android reference</a>):</li>
  </ul>
  
  <p>public static int getMinBufferSize (int sampleRateInHz, int channelConfig, int audioFormat)</p>
  
  <p>The thing I do not understand is what are theses things and how I should use them:
      [Android.Runtime.Register("getMinBufferSize", "(III)I", "")]
      [Android.Runtime.GeneratedEnum]
      [Android.Runtime.GeneratedEnum]</p>
  
  <p>The code in Java was easier:</p>
  
  <pre><code>int buffsize = AudioTrack.getMinBufferSize(_sampleRate, 
  AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT);
  </code></pre>
  
  <p>where _sampleRate is int _sampleRate = 44100; and represents frequency rate.</p>
  
  <p>So, if you at least told me what those three lines in brackets from xamarin documentation are - I would be so grateful.</p>
  
  <p>Thank you in advance and have a great day.</p>
  
  <p>My code so far:</p>
  
  <pre><code>namespace simple_synth
  {
  
  [Activity (Label = "_secondAct")]   //activity that opens the second screen     
  public class _secondAct : Activity
  {
  
  Thread _thread; //audio processing thread    
  int _sRate = 44100; //sampling rate
  bool isRunning = true;  //switch on/off
  
  protected override void OnCreate (Bundle bundle)
  {
  base.OnCreate (bundle);
  SetContentView (Resource.Layout._secondLay);
  
  Button btn2 = FindViewById&lt;Button&gt; (Resource.Id.myButton_synth);
  _audio _audioSound = new _audio ();
  
  
  btn2.Click += (sender, e) =&gt; {
  
  btn2.Text = "GOOD";
  Thread _audioThread = new Thread(_audioSound._makeSound);
  _audioThread.Start(); 
  Console.WriteLine("audio thread: started");
  while (!_audioThread.IsAlive);
  Thread.Sleep(1000);
  _audioSound._stopRequest();
  _audioThread.Join();
  Console.WriteLine("audio thread: terminated now!");
  _audioSound._startRequest();
  };
  }
  }//_secondAct
  
  public class _audio{
  
  private volatile bool _stopItNow;
  
  public void _makeSound(){   // This method will be called when the thread is started. 
  
  while (!_stopItNow) {
  
  Console.WriteLine ("audio thread: is playing the sound...");
  AudioTrack _audioTrack = new AudioTrack (Stream.Music, 22050, 
  ChannelConfiguration.Mono, 
  Android.Media.Encoding.Pcm16bit, 
  _audBuffer.Length, AudioTrackMode.Stream);
  
  _audioTrack.Play ();
  _audioTrack.Write (_audBuffer, 0, _audBuffer.Length);
  }
  
  Console.WriteLine ("audio thread: terminated.");
  
  } //doWork
  
  public void _stopRequest()
  {
  _stopItNow = true;
  }
  
  public void _startRequest()
  {
  _stopItNow = false;
  }
  }
  }
  </code></pre>