本文整理汇总了C#中NAudio.Wave.WaveChannel32类的典型用法代码示例。如果您正苦于以下问题:C# WaveChannel32类的具体用法?C# WaveChannel32怎么用?C# WaveChannel32使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WaveChannel32类属于NAudio.Wave命名空间,在下文中一共展示了WaveChannel32类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
}
}
}
开发者ID:voltagex,项目名称:junkcode,代码行数:29,代码来源:Player.cs
示例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();
}
开发者ID:jackgllghr,项目名称:CS422Assignment3,代码行数:29,代码来源:Form1.cs
示例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]);
}
}
开发者ID:probuilderz,项目名称:balloon,代码行数:27,代码来源:BonIverStemPlayer.cs
示例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;
}
开发者ID:Veggie13,项目名称:Genesis,代码行数:28,代码来源:SoundResource.cs
示例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
}
开发者ID:LuckyLuik,项目名称:_GLDNBT,代码行数:25,代码来源:NAudioSample.cs
示例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));
}
开发者ID:miktemk,项目名称:AudioBooker,代码行数:35,代码来源:TestMix.cs
示例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;
}
}
开发者ID:grazulis,项目名称:KinectRainbowSynth,代码行数:27,代码来源:PianoSynth.cs
示例8: playbackFile
public void playbackFile(string filename)
{
WaveFileReader reader = new WaveFileReader(filename);
WaveChannel32 channelStream = new WaveChannel32(reader);
mixer.AddInputStream(channelStream);
channelStream.Position = 0;
}
开发者ID:hyupeng,项目名称:CSharp-Piano-Test,代码行数:7,代码来源:AudioPlayer.cs
示例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));
}
}
开发者ID:stahlnow,项目名称:Timeliner,代码行数:27,代码来源:AudioTrack.cs
示例10: MixDiffStream
public MixDiffStream(string fileName)
{
WaveFileReader reader = new WaveFileReader(fileName);
offsetStream = new WaveOffsetStream(reader);
channelSteam = new WaveChannel32(offsetStream);
muted = false;
volume = 1.0f;
}
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:8,代码来源:MixDiffStream.cs
示例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;
}
开发者ID:LuckyLuik,项目名称:AudioVSTToolbox,代码行数:8,代码来源:VSTStream.cs
示例12: MixerForm
public MixerForm(WaveChannel32 channel)
{
InitializeComponent();
waveChannel = channel;
tbPan.Value = 50+(int)(channel.Pan*50.0f);
tbVolume.Value = (int)(channel.Volume*100.0f);
}
开发者ID:Zoadian,项目名称:md-config-tool,代码行数:8,代码来源:MixerForm.cs
示例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;
}
开发者ID:hyupeng,项目名称:CSharp-Piano-Test,代码行数:8,代码来源:Key.cs
示例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;
}
开发者ID:chantsunman,项目名称:helix-toolkit,代码行数:9,代码来源:AudioPlayback.cs
示例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;
}
开发者ID:JonBarnard,项目名称:Rhythm-Machine,代码行数:9,代码来源:Mp3Player.cs
示例16: AddIntroOutro
private static void AddIntroOutro(string SermonFileName = "",
string IntroFileName = "",
string OutroFileName = "",
double StartSermonTime = 0,
double StartOutroTime = 0,
string ResultingFile = "")
{
if (String.IsNullOrWhiteSpace(SermonFileName)) throw new ArgumentException("SermonFileName must reference a valid file.");
if (String.IsNullOrWhiteSpace(IntroFileName)) throw new ArgumentException("IntroFileName must reference a valid file.");
if (String.IsNullOrWhiteSpace(OutroFileName)) throw new ArgumentException("OutroFileName must reference a valid file.");
if (String.IsNullOrWhiteSpace(ResultingFile)) ResultingFile = Settings.Default.IntroOutroDirectory;
WaveFileReader intro = new WaveFileReader(IntroFileName);
WaveFileReader outro = new WaveFileReader(OutroFileName);
WaveFileReader audio = new WaveFileReader(SermonFileName);
WaveMixerStream32 mixer = new WaveMixerStream32();
//mixer.AutoStop;
WaveOffsetStream audioOffsetted = new WaveOffsetStream(
audio,
TimeSpan.FromSeconds(StartSermonTime), //N seconds after start of intro.
TimeSpan.Zero,
audio.TotalTime);
TimeSpan outroOffset = TimeSpan.FromSeconds(StartSermonTime) + audio.TotalTime - TimeSpan.FromSeconds(StartOutroTime);
WaveOffsetStream outroOffsetted = new WaveOffsetStream(
outro,
outroOffset,
TimeSpan.Zero,
outro.TotalTime);
WaveChannel32 intro32 = new WaveChannel32(intro);
intro32.PadWithZeroes = false;
mixer.AddInputStream(intro32);
WaveChannel32 outro32 = new WaveChannel32(outroOffsetted);
outro32.PadWithZeroes = false;
mixer.AddInputStream(outro32);
WaveChannel32 audio32 = new WaveChannel32(audioOffsetted);
audio32.PadWithZeroes = false;
mixer.AddInputStream(audio32);
FileInfo file = new FileInfo(SermonFileName);
if (!Directory.Exists(ResultingFile)) Directory.CreateDirectory(ResultingFile);
string FileOut = String.Format(@"{0}\{1}", ResultingFile, file.Name);
WaveFileWriter.CreateWaveFile(FileOut, new Wave32To16Stream(mixer));
}
开发者ID:jakelly,项目名称:SermonProcessor,代码行数:55,代码来源:Program.cs
示例17: CanCreateWavFileFromWaveChannel32
public void CanCreateWavFileFromWaveChannel32()
{
string inFile = @"F:\Recording\wav\pcm\16bit mono 8kHz.wav";
string outFile = @"F:\Recording\wav\pcm\32bit stereo 8kHz.wav";
if (!File.Exists(inFile))
{
Assert.Ignore("Input test file not found");
}
var audio32 = new WaveChannel32(new WaveFileReader(inFile));
audio32.PadWithZeroes = false;
WaveFileWriter.CreateWaveFile(outFile, audio32);
}
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:12,代码来源:WaveChannel32Tests.cs
示例18: CreateInputStream
private static WaveStream CreateInputStream(string fileName)
{
WaveChannel32 inputStream;
WaveStream readerStream = null;
if (fileName.EndsWith(".wav"))
{
readerStream = new WaveFileReader(fileName);
}
//else if (fileName.EndsWith(".wma"))
//{
// // readerStream = new WMAFileReader2(fileName);
// MemoryStream memoryStream = new MemoryStream();
// using (FileStream infile = new FileStream(fileName, FileMode.Open, FileAccess.Read))
// {
// while (infile.Position < infile.Length)
// {
// byte data = (byte)infile.ReadByte();
// memoryStream.WriteByte(data);
// }
// }
// memoryStream.Position = 0;
// readerStream = new WMAFileReader2(memoryStream);
//}
else
{
throw new InvalidOperationException("Unsupported extension");
}
// Provide PCM conversion if needed
if (readerStream.WaveFormat.Encoding != WaveFormatEncoding.Pcm)
{
readerStream = WaveFormatConversionStream.CreatePcmStream(readerStream);
readerStream = new BlockAlignReductionStream(readerStream);
}
// Provide conversion to 16 bits if needed
if (readerStream.WaveFormat.BitsPerSample != 16)
{
var format = new WaveFormat(readerStream.WaveFormat.SampleRate,
16, readerStream.WaveFormat.Channels);
readerStream = new WaveFormatConversionStream(format, readerStream);
}
inputStream = new WaveChannel32(readerStream);
return inputStream;
}
开发者ID:AlexShkor,项目名称:GestoMusic,代码行数:49,代码来源:Program.cs
示例19: MyItemControl
public MyItemControl(Word word)
{
InitializeComponent();
_word = word;
Picture = null;// con.ByteToWPFImage(word.Picture);
waveReader = new WaveFileReader(con.byteArrayToStream(_word.Sound));
SoundLength = waveReader.TotalTime;
wc = new WaveChannel32(waveReader);
audioOutput = new DirectSoundOut();
audioOutput.Init(wc);
track.ValueChangedManually += track_PositionChangedManually;
myTrack.ValueChangedManually += track_PositionChangedManually;
myTrack.MouseLeftButtonDown += track_MouseLeftButtonDown;
myTrack.Loaded += track_Loaded;
}
开发者ID:EnthuseSoftware,项目名称:Communica,代码行数:15,代码来源:MyItem.xaml.cs
示例20: CreateInputStream
private WaveStream CreateInputStream(string fileName)
{
WaveChannel32 inputstream;
if (fileName.EndsWith(".mp3"))
{
WaveStream mp3Reader = new Mp3FileReader(fileName);
inputstream = new WaveChannel32(mp3Reader);
}
else
{
throw new InvalidOperationException("Unsupported extension");
}
volumeStream = inputstream;
return volumeStream;
}
开发者ID:wtfmates,项目名称:BasicMusicPlayer,代码行数:15,代码来源:MP3Handling.cs
注:本文中的NAudio.Wave.WaveChannel32类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论