deltabeard / ctrmus

3DS Music Player

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Opus files play with low-pitch

ponjadito23 opened this issue · comments

Opus files play as if they were 44100Hz instead of 48000Hz

Changing the rate of the song without resampling an then converting to opus fixes the issue, but in any other player it will play with high-pitched sound

I can't seem to reproduce this. I've just played both flac and opus files of the same tracks and they sound the same.

In another test, I forcibly set the sample rate of the opus decoder to use 44100Hz which caused all opus files to play slower and at a lower pitch. So I do think it is playing at 48000Hz usually. Forcibly setting the opus decoder to use 48000Hz didn't make a difference to what ctrmus currently does.

I have compiled an attached a version of ctrmus that forces the opus decoder to always use 48000Hz. Could you see if this fixes your issue?
ctrmus.zip

Could it be that your opus file uses a custom sample rate instead of the default 48000Hz used by libopus?

Yes that fixed it, as for the custom sample rate I dont think so since I simply converted my 44.1KHz flac files using foobar2000

libopus is reporting that your file is 44100Hz instead of 48000Hz. I used ffmpeg to convert my 44100Hz flac file to an opus file, and that works fine normally. I could force opus files to play at 48000Hz, but it is possible for opus files to be encoded at other sample rates.
I'll use my friends computer to convert some files to opus using foobar2000 and I'll report back. 😃

I could also upload some samples for you to test

Edit: github doesnt let me upload it so i cant

I've just tested foobar2000 and can confirm the issue is with foobar2000 or opus-tools 0.1.9. The current version of opus-tools is 0.1.10 but a binary for it isn't available on the opus website.
The mediainfo tool on Linux reports the converted file as 44100Hz, so ctrmus is playing it at the correct speed. It's just that either foobar2000 or opus-tools 0.1.9 is not setting the correct sample rate.

Consider using an alternative opus decoder such as ffmpeg or compile the latest version of opus-tools and use that with foobar2000.

I tried using a compiled version of opusenc from here https://github.com/Chocobo1/opus-tools_win32-build/releases and it still happens, I will try using ffmpeg as you said.

Did using ffmpeg work? I just used opusenc to convert a flac to opus and that has the same issue. This is very odd considering opusenc is the de facto opus encoder. According to this wiki page, an opus decoder should output at 48000Hz. Additionally, I read elsewhere that the sampling rate stored in the file is if the user wants to encode to another format at the original sampling rate.

I think I'm going to force 48000Hz output with opus in ctrmus.

I've just had a look at opusfile.h:237 and indeed it says an opus file must be decoded at 48000Hz. This will be fixed shortly.

Fixed in 4f4228b. Expect a new release shortly. Apologies for closing this prematurely.