I am trying to save a mix file. It works, but not when I add an effect to the mix.
it throws an error because the file goes to 2 Gb.
I do not know why.
I read in a file and I changed the volume in it and then I add it to a mix and try to save it.
but it does not stop. after this I can play the file but it is like 2.49 hours long. but the 1st part of the file in right...
I do not understand, I can play the mix with the effect and it works right. it even stop when is it done...
but why with I try and write it, it does not?
this is my code:
can someone please help me?
this is the effect file:
it throws an error because the file goes to 2 Gb.
I do not know why.
I read in a file and I changed the volume in it and then I add it to a mix and try to save it.
but it does not stop. after this I can play the file but it is like 2.49 hours long. but the 1st part of the file in right...
I do not understand, I can play the mix with the effect and it works right. it even stop when is it done...
but why with I try and write it, it does not?
this is my code:
MixingSampleProvider mixernew = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(44100, 2));
try
{
for (int y = 0; y < file.Count; y++)
{
audioFileReader = new AudioFileReader(file[y]);
mixernew.AddMixerInput((ISampleProvider)audioFileReader);
}
if (effectflat == true)
{
for (int i = 0; i < stream.Count; i++)
{
mixernew.AddMixerInput(stream[i]);
}
}
SampleToWaveProvider mixer3 = new SampleToWaveProvider(mixernew);
SaveFileDialog save2 = new SaveFileDialog();
save2.Filter = "Wave file (*.wav)|*.wav;";
if (save2.ShowDialog() != DialogResult.OK) return;
WaveFileWriter.CreateWaveFile(save2.FileName, mixer3);
}
catch (Exception)
{
MessageBox.Show("error file not mad");
}
MessageBox.Show("File Saved");
I am about done with a program I am working on and this is the last part I need help withcan someone please help me?
this is the effect file:
using System;
using System.IO;
using System.Collections.Generic;
using NAudio.Wave;
namespace Isochronic_tones_generator
{
public class EffectStream : WaveStream
{
public WaveStream SourceStream { get; set; }
public List<IEffect> Effects { get; private set; }
static int counter;
public EffectStream(WaveStream stream)
{
this.SourceStream = stream;
this.Effects = new List<IEffect>();
number = 1;
counter = 0;
}
public float number { get; set; }
public override long Length
{
get { return SourceStream.Length; }
}
public override long Position
{
get
{
return SourceStream.Position;
}
set
{
SourceStream.Position = value;
}
}
public override WaveFormat WaveFormat
{
get { return SourceStream.WaveFormat; }
}
public override int Read(byte[] buffer, int offset, int count)
{
Console.WriteLine("DirectSoundOut requested {0} bytes", count);
int read = SourceStream.Read(buffer, offset, count);
for (int i = 0; i < read / 4; i++)
{
float sample = BitConverter.ToSingle(buffer, i * 4);
sample = sample * number;
byte[] bytes = BitConverter.GetBytes(sample);
//bytes.CopyTo(buffer, i * 4);
buffer[i * 4 + 0] = bytes[0];
buffer[i * 4 + 1] = bytes[1];
buffer[i * 4 + 2] = bytes[2];
buffer[i * 4 + 3] = bytes[3];
}
return read;
}
}
}