Hi there,
After reading the terminology, basic concepts and several forum topics I still haven’t quite figured out how to use the byte array obtained from Sound::readData to plot out a sound it’s entire waveform. Here’s what I have so far (C#)

//load the sound
FMOD.RESULT result = system.createStream(audioFile, FMOD.MODE.HARDWARE | FMOD.MODE.OPENONLY | FMOD.MODE.ACCURATETIME, ref sound);

        //get the length in PCM bytes of the sound
        uint soundLengthInBytes = 0;
        sound.getLength(ref soundLengthInBytes,FMOD.TIMEUNIT.PCMBYTES);

        //create pointer
        IntPtr i1 = Marshal.AllocHGlobal((int)soundLengthInBytes);

        //read all the data in the buffer
        uint actualRead = 0;
        result = sound.readData(i1, soundLengthInBytes, ref actualRead);

        //get the values using the pointer
        byte[] buffer = new byte[soundLengthInBytes];
        System.Runtime.InteropServices.Marshal.Copy(i1, buffer, 0, (int)soundLengthInBytes);

        short[] leftAudioArray = new short[buffer.Length / 4];
        short[] rightAudioArray = new short[buffer.Length / 4];

        for (int i = 0; i < buffer.Length; i = i + 4)
            leftAudioArray[i / 4] = BitConverter.ToInt16(buffer, i);
            rightAudioArray[i / 4] = BitConverter.ToInt16(buffer, i + 2);



Does this make sense? Am I right about the left and rightAudioArray?

If so, how would I use these values to plot? I found posts using the terms peakvalues and weakvalues but I’m not really sure exactly. Some fresh insight would be highly appreciated.



  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.