Search code examples
c#dllusingstatements

What using statement do I need for WavReader and FlacWriter?


so far I have these using statements:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using Newtonsoft.Json;
using System.Threading;
using NAudio.Wave;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using Alvas.Audio;

I'm trying to write a wav to flac converter. Here is the function:

public static void flac_converter()
{
    string inputFile = Path.Combine("wav ", input);
    string outputFile = Path.Combine("flac", Path.ChangeExtension(input, ".flac"));

    if (!File.Exists(inputFile))
        throw new ApplicationException("Input file " + inputFile + " cannot be found!");

    WavReader wav = new WavReader(inputFile);

    using (var flacStream = File.Create(outputFile))
    {
        FlacWriter flac = new FlacWriter(flacStream, wav.BitDepth, wav.Channels, wav.SampleRate);
        // Buffer for 1 second's worth of audio data
        byte[] buffer = new byte[wav.Bitrate / 8];
        int bytesRead;
        do
        {
            bytesRead = wav.InputStream.Read(buffer, 0, buffer.Length);
            flac.Convert(buffer, 0, bytesRead);
        } while (bytesRead > 0);
        flac.Dispose();
        flac = null;
    }
}

But I get this error: "The Type of Namespace 'WavReader' cannot be found" I also get this error: "The Type or Namespace 'FlacWriter' cannot be found"

I know I have to do two things, download the appropriate lib, then all teh DLL files to the reference of the project and also add "using blahBlah;"

However, I don't know what DLL i need, or what using statements I need to get rid of these errors. Anyone know?


Solution

  • change the spelling of wavreader to wavereader. It should work out.