MaKiPL / OpenVIII-monogame

Open source Final Fantasy VIII engine implementation in C# working on Windows and Linux (Android and iOS planned too!) [Monogame]
MIT License
642 stars 59 forks source link

Soundeffects working in linux via ffmpeg. #30

Closed Sebanisu closed 5 years ago

Sebanisu commented 5 years ago

Once I had it writing valid wav files that I could play in VLC. It was just a few tweaks to getting it to play sound in code.

Had to replace the decode() function for ffcc. Because the old one only read files with one frame per packet. But sound formats with a constant bitrate can be multiple frames per packet.

Had to make some variables more flexible. All the movies and ogg music are stereo and 44100 or 48000 so I had hard coded some of those values in.

The way it reads sounds from memory is coping the data into a pointer and it reads from the pointer like it's a file. This took some fiddling to get to work.

I removed the function to read audio right out of the decoded frame. Because for some reason it was causing static when reading the decompressed adpcm audio. So everything goes through the resampler.

Might still be better to use naudio in windows as it works and it's fast. Unsure what the speed difference is. I do know that the sound is slow on my linux vm. Takes a sec to play. Maybe just some optimization would be needed to fix that.