11,578 questions
Try replacing public void New(string fileName)
with public WavReader(string fileName)
.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The error is 'does not contain a contructor that takes one argument'.
I tried WavReader reader = new WavReader(@"")
Here is the class I wrote...
using System;
using System.IO;
namespace WAV2MP3
{
public class WavReader
{
private Int32 chunkID;
private Int32 chunkSize;
private Int32 format;
private Int32 subchunk1ID;
private Int32 subchunk1Size;
private Int16 audioFormat;
private Int16 numberOfChannels;
private Int32 sampleRate;
private Int32 byteRate;
private Int16 blockAlign;
private Int16 bitsPerSample;
private Int32 subchunk2ID;
private Int32 subchunk2Size;
private Int32 data;
public void New(string fileName)
{
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
chunkID = br.ReadInt32();
chunkSize = br.ReadInt32();
format = br.ReadInt32();
subchunk1ID = br.ReadInt32();
subchunk1Size = br.ReadInt32();
audioFormat = br.ReadInt16();
numberOfChannels = br.ReadInt16();
sampleRate = br.ReadInt32();
byteRate = br.ReadInt32();
blockAlign = br.ReadInt16();
bitsPerSample = br.ReadInt16();
subchunk2ID = br.ReadInt32();
subchunk2Size = br.ReadInt32();
data = br.ReadInt32();
br.Close();
fs.Close();
}
public Int32 ChunkID
{
get { return chunkID; }
}
public Int32 ChunkSize
{
get { return chunkSize; }
}
public Int32 Format
{
get { return format; }
}
public Int32 Subchunk1ID
{
get { return subchunk1ID; }
}
public Int32 Subchunk1Size
{
get { return subchunk1Size; }
}
public Int16 AudioFormat
{
get { return audioFormat; }
}
public Int16 NumberOfChannels
{
get { return numberOfChannels; }
}
public Int32 SampleRate
{
get { return sampleRate; }
}
public Int32 ByteRate
{
get { return byteRate; }
}
public Int16 BlockAlign
{
get { return blockAlign; }
}
public Int16 BitsPerSample
{
get { return bitsPerSample; }
}
public Int32 Subchunk2ID
{
get { return subchunk2ID; }
}
public Int32 Subchunk2Size
{
get { return subchunk2Size; }
}
public Int32 Data // same as subchunk2Size
{
get { return subchunk2Size; }
}
}
}
Try replacing public void New(string fileName)
with public WavReader(string fileName)
.