Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.wav file created with naudio always returns :: fmt (2) error when passed to GetAudioLength #11

Open
PythonCircuit opened this issue May 15, 2024 · 1 comment

Comments

@PythonCircuit
Copy link

PythonCircuit commented May 15, 2024

When using NAudio to save a .wav file from my recording, I cannot extract the proper length of the recording when passing to GetAudioLength from the lib.

As far as I can tell I am creating the .wav file as it should be created and it plays back audio perfectly fine... Do I need to change these parameters to work with the library?

Rate, Bits, Channels?

I.E.
waveIn.WaveFormat = new WaveFormat(44100, 16, 1);

var x_length = Tools.GetAudioLength(fufilePath);

So this problem seems to be exclusive to my .wav files however if I use the .wav file you provided it works fine. Is there a specifics to the wav file creation you could provide?

@yamachu
Copy link
Owner

yamachu commented May 16, 2024

Thanks for reporting the Issue.
If you read the README, you will see the purpose of this repository.
It is a wrapper library for World and the original code can be found here

https://github.com/mmorise/World/blob/f8dd5fb289db6a7f7f704497752bf32b258f9151/tools/audioio.cpp#L172-L215

If you look at the CheckHeader function called from this code, you will see that it only targets wav files with a specific header.
Make sure the wav file you created follows that format.

I do not use NAudio, so I cannot assist you in creating wav files when using NAudio.

If you are using linux or macos, you can check the format by using the file or xxd command.

example

 xxd sampleapp/sample_voice.wav|head -n3
00000000: 5249 4646 6c46 0400 5741 5645 666d 7420  RIFFlF..WAVEfmt
00000010: 1000 0000 0100 0100 803e 0000 007d 0000  .........>...}..
00000020: 0200 1000 6461 7461 4846 0400 1d00 3300  ....dataHF....3.

This header follows the

  • RIFF format.
  • The WAVEfmt field is 16 bytes.
  • PCM format
  • It is monoral.
  • Sampling rate is 16kHz.
  • etc...
  • 16bit depth

Make sure that the wav file fulfills these conditions, except for the sampling rate.
Also make sure the wav file is not a toooooooooooooooooooooooo long file that exceeds the specifications.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants