getting the sampling of audio

I am trying to find the easiest way to find the sample rate of input audio (e.g. a microphone).
there are multiple way I have found, the problem is I have no idea which one is more applicable, or which uses less processing power, or in general is the fastest/best.

1st off we have: Unity - Scripting API: AudioClip.samples

AudioClip.samples

now this one I am assuming, the audio has to be written to an audio clip then this will be used.

2nd: Unity - Scripting API: AudioSettings.outputSampleRate

AudioSettings.outputSampleRate

Self Explanatory.

3rd: Unity - Scripting API: AudioSource.GetSpectrumData

audio.GetSpectrumData(int,int,FFTWindow)

I am assuming this, gets data from and audio input device, puts it into an array and the array length is the number of samples.

4th:
Should i just specify the sample rate number to be 256
As I have seen this been used a lot on audio scripts.

Yes, you can leave it on 256 I use it on most cases, you will not notice much difference in quality if you use more, it only will use more resources for practically the same result. Also if you call GetSpectrumData the 256 is the maximum amount it can load into memory, so if you don’t think 256 will be your complete audio track, you need to increase it. But most of the time the track is short enough to fit the 256 quota.

(As you have seen in my mic script I decided to take an avarage of the mic input spectrum, this gives a more stable result). The same technique can be handled in an audio clip as seen in here.

#pragma strict


var audioSource:AudioSource;


private var SpectrumMax:float=256;
var Sensitivity:float=300;



	function LateUpdate () {
	
	    var spectrum : float=GetDataStream(); 
	    var Volume:float=audioSource.volume;
	    
	     
	
	 //hera you can apply stuff for each spectrum value
	    for (var i = 1; i < SpectrumMax; i++) {
	   
	    	    }
		  	
	//reset the loop when max value is reached (normaly this does not happen but just in case)
		if(i>=SpectrumMax){
		i=1;
		}
	}
	
	
	
	
	
function GetDataStream(){
   var dataStream: float[]  = new float[SpectrumMax];
       var audioValue: float = 0;
        audioSource.GetOutputData(dataStream,0);
        
        for(var i in dataStream){
            audioValue += Mathf.Abs(i);
        }
        return audioValue/SpectrumMax;
        

}

I have used GetSpectrum myself, but GetData with this calculation below gives a much more stable result and is more thrust worthy for using on other components.(This is pullet from my audio detection system wich uses audioclips