index.js
function getFormat (obj) {
	//undefined format - no format-related props, for sure
	if (!obj) return {}

	//if is string - parse format
	if (typeof obj === 'string' || obj.id) {
		return parse(obj.id || obj)
	}

	//if audio buffer - we know it’s format
	else if (isAudioBuffer(obj)) {
		var arrayFormat = fromTypedArray(obj.getChannelData(0))
		return {
			sampleRate: obj.sampleRate,
			channels: obj.numberOfChannels,
			samplesPerFrame: obj.length,
			float: true,
			signed: true,
			bitDepth: arrayFormat.bitDepth
		}
	}

	//if is array - detect format
	else if (ArrayBuffer.isView(obj)) {
		return fromTypedArray(obj)
	}

	//FIXME: add AudioNode, stream detection

	//else detect from obhect
	return fromObject(obj)
}
function getFormat (obj) {
	//undefined format - no format-related props, for sure
	if (!obj) return {}

	//if is string - parse format
	if (typeof obj === 'string' || obj.id) {
		return parse(obj.id || obj)
	}

	//if audio buffer - we know it’s format
	else if (isAudioBuffer(obj)) {
		var arrayFormat = fromTypedArray(obj.getChannelData(0))
		return {
			sampleRate: obj.sampleRate,
			channels: obj.numberOfChannels,
			samplesPerFrame: obj.length,
			float: true,
			signed: true,
			bitDepth: arrayFormat.bitDepth
		}
	}

	//if is array - detect format
	else if (ArrayBuffer.isView(obj)) {
		return fromTypedArray(obj)
	}

	//FIXME: add AudioNode, stream detection

	//else detect from obhect
	return fromObject(obj)
}
function getFormat ( obj ) { //undefined format - no format-related props, for sure if ( ! obj ) return { } //if is string - parse format if ( typeof obj === 'string' || obj . id ) { return parse ( obj . id || obj ) } //if audio buffer - we know it’s format else if ( isAudioBuffer ( obj ) ) { var arrayFormat = fromTypedArray ( obj . getChannelData ( 0 ) ) return { sampleRate : obj . sampleRate , channels : obj . numberOfChannels , samplesPerFrame : obj . length , float : true , signed : true , bitDepth : arrayFormat . bitDepth } } //if is array - detect format else if ( ArrayBuffer . isView ( obj ) ) { return fromTypedArray ( obj ) } //FIXME: add AudioNode, stream detection //else detect from obhect return fromObject ( obj ) }
Get format info from any object, unnormalized.
Get format info from any object unnormalized .