本文整理汇总了C#中NAudio.Wave.WaveChannel32类的典型用法代码示例。如果您正苦于以下问题:C# WaveChannel32类的具体用法?C# WaveChannel32怎么用?C# WaveChannel32使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WaveChannel32类属于NAudio.Wave命名空间,在下文中一共展示了WaveChannel32类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlayFromFile
public static void PlayFromFile(string filename, int frequency)
{
using (
FileStream stream = new FileStream(filename, FileMode.Open))
{
var waveFormat = WaveFormat.CreateMuLawFormat(frequency * 2, 1);
var reader = new NAudio.Wave.RawSourceWaveStream(stream, waveFormat);
using (WaveStream convertedStream = WaveFormatConversionStream.CreatePcmStream(reader))
{
convertedStream.Seek(0, 0);
WaveOutEvent player = new WaveOutEvent();
WaveChannel32 volumeStream = new WaveChannel32(convertedStream);
player.Init(volumeStream);
player.Play();
while (player.PlaybackState == PlaybackState.Playing)
{
System.Threading.Thread.Sleep(100);
var input = Console.ReadKey();
if (input.KeyChar > 1) ;
{
player.Stop();
}
}
}
}
}
示例2: Form1
public Form1()
{
_serialPort.PortName = "COM6";
_serialPort.BaudRate = 9600;
_serialPort.Parity = Parity.None;
_serialPort.DataBits = 8;
_serialPort.StopBits = StopBits.Two;
_serialPort.Handshake = Handshake.None;
_serialPort.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
_serialPort.Open();
//Set up audio outputs
jaws[0] = new WaveOut();
jaws[1] = new WaveOut();
jaws[2] = new WaveOut();
var jawsAudio1 = new WaveChannel32(new WaveFileReader("Sounds/Jaws3.wav"));
jaws[0].Init(jawsAudio1);
var jawsAudio2 = new LoopStream(new WaveFileReader("Sounds/Jaws2.wav"));
jaws[1].Init(jawsAudio2);
var jawsAudio3 = new LoopStream(new WaveFileReader("Sounds/Jaws1.wav"));
jaws[2].Init(jawsAudio3);
//Set the shark to a random position
resetShark();
InitializeComponent();
}
示例3: BonIverStemPlayer
// set everything up
public BonIverStemPlayer(Engine.Engine engine) {
mixer.AutoStop = false;
waveOutDevice.Init(mixer);
Engine = engine;
// load in each of our files
reader[0] = new WaveFileReader(@"C:\\Users\\Badger\\repos\\balloon\\SkeletalTracking\\boniver\\bangorkook.wav");
reader[1] = new WaveFileReader(@"C:\Users\Badger\repos\balloon\SkeletalTracking\boniver\chippewa_falls.wav");
reader[2] = new WaveFileReader(@"C:\Users\Badger\repos\balloon\SkeletalTracking\boniver\eleva.wav");
reader[3] = new WaveFileReader(@"C:\Users\Badger\repos\balloon\SkeletalTracking\boniver\gilman.wav");
reader[4] = new WaveFileReader(@"C:\Users\Badger\repos\balloon\SkeletalTracking\boniver\grand_rapids.wav");
reader[5] = new WaveFileReader(@"C:\Users\Badger\repos\balloon\SkeletalTracking\boniver\heigh_on.wav");
reader[6] = new WaveFileReader(@"C:\Users\Badger\repos\balloon\SkeletalTracking\boniver\lake_hallie.wav");
reader[7] = new WaveFileReader(@"C:\Users\Badger\repos\balloon\SkeletalTracking\boniver\le_grange_wi.wav");
reader[8] = new WaveFileReader(@"C:\Users\Badger\repos\balloon\SkeletalTracking\boniver\long_plain.wav");
reader[9] = new WaveFileReader(@"C:\Users\Badger\repos\balloon\SkeletalTracking\boniver\mandolin_wa.wav");
reader[10] = new WaveFileReader(@"C:\Users\Badger\repos\balloon\SkeletalTracking\boniver\virginia.wav");
// set the starting positions
// and load into the mixer
for (int i = 0; i < 11; i++) {
channelStream[i] = new WaveChannel32(reader[i]);
channelStream[i].Position = 0;
mixer.AddInputStream(channelStream[i]);
}
}
示例4: SoundResource
public SoundResource(ResourceManager mgr, string fullName, Stream stream, Format fmt)
{
_manager = mgr;
FullName = fullName;
switch (fmt)
{
case Format.MP3:
{
Mp3FileReader mp3 = new Mp3FileReader(stream);
_reader = mp3;
break;
}
case Format.WAV:
{
WaveFileReader wav = new WaveFileReader(stream);
_reader = wav;
break;
}
default:
throw new InvalidOperationException("Unsupported extension.");
}
_stream = new WaveChannel32(_reader);
_stream.PadWithZeroes = false;
_wavDevice.PlaybackStopped += _wavDevice_PlaybackStopped;
}
示例5: AudioSample
public AudioSample(string fileName)
{
_fileName = fileName;
WaveFileReader reader = new WaveFileReader(fileName);
//offsetStream = new WaveOffsetStream(reader);
//channelStream = new WaveChannel32(offsetStream);
channelStream = new WaveChannel32(reader);
muted = false;
volume = 1.0f;
#region ReverseStuff
//Code to reverse
NAudioBufferReverse nbr = new NAudioBufferReverse();
reversedSample = new byte[(int)channelStream.Length];
channelStream.Read(reversedSample, 0, (int)channelStream.Length);
bytesPerSample = (channelStream.WaveFormat.BitsPerSample / 8) * channelStream.WaveFormat.Channels;
reversedSample = nbr.reverseSample(reversedSample, (int)channelStream.Length, bytesPerSample);
#endregion
}
示例6: TestMix
public TestMix()
{
//WaveStream str1 = new Mp3FileReader("C:\\Users\\mtemkine\\Desktop\\snd\\guitar1.mp3");
//WaveStream str2 = new Mp3FileReader("C:\\Users\\mtemkine\\Desktop\\snd\\molecules.mp3");
//WaveMixerStream32 mix = new WaveMixerStream32(new [] {str1, str2}, false);
var background = new Mp3FileReader("C:\\Users\\mtemkine\\Desktop\\snd\\ferriss.mp3");
var message = new Mp3FileReader("C:\\Users\\mtemkine\\Desktop\\snd\\guitar1.mp3");
var mixer = new WaveMixerStream32();
mixer.AutoStop = true;
var messageOffset = background.TotalTime;
var messageOffsetted = new WaveOffsetStream(message, TimeSpan.FromSeconds(1.5), TimeSpan.Zero, message.TotalTime.Subtract(TimeSpan.FromSeconds(1)));
var background32 = new WaveChannel32(background);
background32.PadWithZeroes = false;
background32.Volume = 0.9f;
var message32 = new WaveChannel32(messageOffsetted);
message32.PadWithZeroes = false;
message32.Volume = 0.7f;
var s1 = new RawSourceWaveStream(background32, new WaveFormat(8000, 16, 1));
var s2 = new RawSourceWaveStream(message32, new WaveFormat(8000, 16, 1));
WaveFormat targetFormat = WaveFormat.CreateIeeeFloatWaveFormat(128, 2);
var ss1 = new WaveFormatConversionStream(targetFormat, background32);
//var c = new WaveFormatConversionStream(WaveFormat.CreateALawFormat(8000, 1), background32);
//var stream_background32 = new WaveFormatConversionStream(new WaveFormat(256, 32, 2), background32);
//var stream_message32 = new WaveFormatConversionStream(new WaveFormat(256, 32, 2), message32);
mixer.AddInputStream(s1);
mixer.AddInputStream(s2);
WaveFileWriter.CreateWaveFile("mycomposed.wav", new Wave32To16Stream(mixer));
}
示例7: PianoSynth
public PianoSynth()
{
mixer = new WaveMixerStream32();
mixer.AutoStop = false;
int i = 0;
foreach (var note in noteFiles)
{
reader[i] = new WaveFileReader(note);
offsetStream[i] = new WaveOffsetStream(reader[i]);
channelSteam[i] = new WaveChannel32(offsetStream[i]);
channelSteam[i].Position = channelSteam[i].Length;
mixer.AddInputStream(channelSteam[i]);
i++;
}
if (waveOutDevice == null)
{
waveOutDevice = new WaveOut {DeviceNumber = 0};
waveOutDevice.Init(mixer);
waveOutDevice.Volume = 0;
waveOutDevice.Play();
waveOutDevice.Volume = 100;
}
}
示例8: playbackFile
public void playbackFile(string filename)
{
WaveFileReader reader = new WaveFileReader(filename);
WaveChannel32 channelStream = new WaveChannel32(reader);
mixer.AddInputStream(channelStream);
channelStream.Position = 0;
}
示例9: LoadFile
public void LoadFile()
{
var wave = new WaveChannel32(new Mp3FileReader(@"file.mp3"));
var buffer = new byte[16384*2];
var read = 0;
var i = 0;
while (wave.Position < wave.Length)
{
read = wave.Read(buffer, 0, 16384*2);
var max = 0f;
var absMax = 0f;
for (int j = 0; j < read / 4; j++)
{
var s = BitConverter.ToSingle(buffer, j*4);
var abs = Math.Abs(s);
if (abs > absMax)
{
absMax = abs;
max = s;
}
}
Samples.Add(new TLSample(i += 2, max));
}
}
示例10: MixDiffStream
public MixDiffStream(string fileName)
{
WaveFileReader reader = new WaveFileReader(fileName);
offsetStream = new WaveOffsetStream(reader);
channelSteam = new WaveChannel32(offsetStream);
muted = false;
volume = 1.0f;
}
示例11: SetInputWave
public void SetInputWave(string waveInputFilePath, float volume) {
// 4 bytes per sample (32 bit)
this.wavFileReader = new WaveFileReader(waveInputFilePath);
this.wavStream = new WaveChannel32(this.wavFileReader);
// Leave headroom for plugin processing (0.20 seems OK, any higher causes digital clipping)
this.wavStream.Volume = volume;
}
示例12: MixerForm
public MixerForm(WaveChannel32 channel)
{
InitializeComponent();
waveChannel = channel;
tbPan.Value = 50+(int)(channel.Pan*50.0f);
tbVolume.Value = (int)(channel.Volume*100.0f);
}
示例13: Key
public Key(string name, string sampleFile)
{
this.notePitch = name;
WaveFileReader reader = new WaveFileReader(sampleFile);
offsetStream = new WaveOffsetStream(reader);
channelStream = new WaveChannel32(offsetStream);
channelStream.Position = channelStream.Length;
}
示例14: OpenMp3Stream
private static WaveChannel32 OpenMp3Stream(string fileName)
{
WaveChannel32 inputStream;
WaveStream mp3Reader = new Mp3FileReader(fileName);
WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(mp3Reader);
WaveStream blockAlignedStream = new BlockAlignReductionStream(pcmStream);
inputStream = new WaveChannel32(blockAlignedStream);
return inputStream;
}
示例15: CreateInputStream
private static WaveStream CreateInputStream(byte[] mediacontent)
{
var memoryStream = new MemoryStream(mediacontent);
var mp3Reader = new Mp3FileReader(memoryStream);
var inputStream = new WaveChannel32(mp3Reader);
return inputStream;
}