Example #1
0
        } // loading jingle

        private void GetRawData(FMOD.Sound tempSound, int channels, int bits, uint pcm)
        {
            tempSound.CheckNull("tempSound");
            uint   len1 = 0, len2 = 0;
            IntPtr ptr1 = IntPtr.Zero, ptr2 = IntPtr.Zero;

            switch (bits)
            {
            case 16:
            {
                FMOD.RESULT result = tempSound.@lock(0, (uint)(pcm * channels * sizeof(short)), ref ptr1, ref ptr2, ref len1, ref len2);
                ErrorCheck(result);

                SoundDataBuffer = new CircularBuffer((int)(pcm * channels));
                Marshal.Copy(ptr1, SoundDataBuffer.Buffer, 0, (int)(len1 / sizeof(short)));
                if (len2 > 0)
                {
                    Marshal.Copy(ptr2, SoundDataBuffer.Buffer, (int)(len1 / sizeof(short)), (int)(len2 / sizeof(short)));
                }

                tempSound.unlock(ptr1, ptr2, len1, len2);
                break;
            }

            default:
                throw new InvalidOperationException("Bits count unsupported");
            }
        }