FlacReader + WavWriter

As a follow-up to my previous article on FLAC and encoding uncompressed audio, I have further developed the Wav2Flac library and added FLAC decoding to the WAVE container. Some key points of this aspect of the WavFlacTest library are:

OK The Wav 2 Flac encoder (even if you have to declare the calling convention in DllImport under VS2010 in order to avoid the “StackImbalance” exception)
The Wav 2 Flac doesn’t work (I use VS2010) - I always get the error in the console “Cannot Open File Stream”
I don’t know how to fix it!
Please help!

It is extremely useful to see this, and I’m using the code for a personal project.

I might humbly suggest perhaps implementing an event system for reporting status and progress within those callbacks, so that the classes can be separated from the console class, as the code can be used in non-console applications (perhaps a Windows Forms app, which is what I’m developing).

I may try and make such changes myself, and converting the code to VB.NET for myself.

For those running into errors and had to convert the project from VS20XX to VS2010+, make sure that you’re not building for “Any CPU”. Create build configuration for x86, and it should work out for you.

Thanks for your kindness and immediate response. But the project you suggestted only shows how to read the inner-tag of a flac, which is not enough. In my opinion, I should learn to convert a flac stream/btye[] into a wav/mp3 stream/byte[] so that the WP7 mediaelment could load it and play it. Reading the inner-tag could make a player elegant but the problem is I couldn’t even make a player work. However, I appreciate you very much and I’m sorry for my poor English.

Is there some new information about the CANNOT PROCESS UNTIL EOF Error? Have the same issue, but only when running without debugging, and can not fix it (I use build configuration for x86). Seems to be a Visual Studio Version problem, will try to install an older version later and test it.

Ok, changing to visual Studio 2008 did not help. Also tried your sample Code without opening it in Studio on 3 different PCs (XP/7). Additional i tried the process_single method. I get always this error when reading the flac file. It always reads the first block, but then fails at the second block.

About the “Cannot process until EOF” error, I think I’ve found the solution.

I had the same error and my test project target framework was .NET Framework 4 Client Profile. I noticed that Stanimir’s test project target framework was .NET Framework 2.0 so I tried to build my project for older version of .NET Framework. I tried 3.5 and it worked.

I have got your project work and have imported the required bits into my project and all appeared to be working
My application takes a stream from microphone passes it through your flac writer then writes it to the Google continuous speech api - i then look to the output stream. Put it all together - should work..
anyway - it didnt! - i started to debug it - i noticed that if stream any flac file through it converted from a wav file it works fine however if i convert wav to flac using your code it doesnt work.
i have tested your generated flac file and it appears okay - also showing identically to a working version of the file in spectro
ive tried the following:
Audacity - wav to flac - works
FLAC frontend - wav to flac - works
vtmblip library (although no streaming option!) - works

As i said your generated flac file tests okay and plays but it will not pass through my application like the others.
sample rate = 16k
bit rate = 16
channels = 1

Ive only started learning about this today so forgive me if ive missed something - ive tried playing around with ur settings but cant get it going either (FlacWriter.cs)

Hello Again,
Ive pulled the flac writer apart and pretty much rewritten it - im still getting the same problem tho.
I’ve been through the documentation and all appears fine.
I noticed though that the file sizes were different and on closer inspection the compression ratios are different (40% vs 10%) - the only thing different i can see which could be causing this is the average bitrate? - orignal file size both are the same
I cant see anywhere in the documentation how to lower the average bitrate from 235 (orignal file had 256 [wav]) to working file: 110Kbps
Any help would be hugely appreciated
Thanks
Levi