I have a database with different words in it, and with the words is a wav file stored in a blob with the pronunciation. I'm stuck trying to get the BLOB to read as a AudioClip for Unity.
So far I have the sound file somewhat resembling my original in the fact that its the same length, but there's a lot of static.
private float [] ConvertByteToFloat ( byte [] array )
{
float[] floatArr = new float [ array.Length / 4 ];
for ( int i = 0; i < floatArr.Length; i++ )
{
if ( !System.BitConverter.IsLittleEndian )
System.Array.Reverse( array, i * 4, 4 );
floatArr [ i ] = System.BitConverter.ToSingle( array, i * 4 );
}
return floatArr;
}
float[] stream = ConvertByteToFloat((byte[]) reader["Sound"]);
AudioClip clip = AudioClip.Create( ( string ) reader [ "Name" ], stream.Length, 2, 44100, false, false );
clip.SetData( stream, 0 );
There was only static earlier when IsLittleEndian was if(true), if not true made it a little more accurate, but still not what it was before.