public override SoundInput TryOpen(IBinaryStream file) { int first = file.ReadByte(); if ((first ^ 0x21) != 0x78) // doesn't look like zlib stream { return(null); } file.Position = 0; using (var input = new XoredStream(file.AsStream, 0x21, true)) using (var zstream = new ZLibStream(input, CompressionMode.Decompress)) { SoundInput sound = null; var wav = new MemoryStream(); try { zstream.CopyTo(wav); wav.Position = 0; sound = new WaveInput(wav); } finally { if (null == sound) { wav.Dispose(); } else { file.Dispose(); } } return(sound); } }
private void UnselectedMircrophoneInput() { if (!CheckIfSoundInputIsUsed()) { SoundInput.StopMicrophoneInputSafely(); } GiveMicrophoneInputSlidersVariables(); }
private void MainForm_Load(object sender, EventArgs e) { // جهت دریافت نمونه های صوتی صوتی از کارت صدا input = new SoundInput(NewInputSamplesArrivedEvent); // آغاز بکار شنود و سدیافت نمونه های صوتی StartListenning(); // بارگزاری طیف رنگ های اسپکتوگراوم GramUtils.LoadPalettes(colorPalleteToolStripMenuItem); }
public override SoundInput TryOpen(IBinaryStream file) { int length = (int)file.Length; if (length < 4) { return(null); } uint signature = file.ReadUInt8(); switch (signature & 0x42) { case 0x42: length -= 3; break; case 0x02: case 0x40: length -= 1; break; default: return(null); } uint key = (signature & 0xBD) ^ 0x6A8CD4E7u; var header = file.ReadBytes(4); file.Position = 1; Decrypt(header, key); SoundInput sound = null; if (header.AsciiEqual("RIFF")) { sound = new WaveInput(DecryptedStream(file, length, key)); } else if (header.AsciiEqual("OggS")) { sound = new OggInput(DecryptedStream(file, length, key)); } if (sound != null) { file.Dispose(); } return(sound); }
private void PlayFile(Entry entry) { SoundInput sound = null; try { SetBusyState(); using (var input = VFS.OpenStream(entry)) { FormatCatalog.Instance.LastError = null; sound = AudioFormat.Read(input); if (null == sound) { if (null != FormatCatalog.Instance.LastError) { throw FormatCatalog.Instance.LastError; } return; } if (AudioDevice != null) { AudioDevice.PlaybackStopped -= OnPlaybackStopped; AudioDevice = null; } CurrentAudio = new WaveStreamImpl(sound); AudioDevice = new WaveOutEvent(); AudioDevice.Init(CurrentAudio); AudioDevice.PlaybackStopped += OnPlaybackStopped; AudioDevice.Play(); var fmt = CurrentAudio.WaveFormat; SetResourceText(string.Format("Playing {0} / {3} / {2}bps / {1}Hz", entry.Name, fmt.SampleRate, sound.SourceBitrate / 1000, CurrentAudio.TotalTime.ToString("m':'ss"))); } } catch (Exception X) { SetStatusText(X.Message); if (null != sound) { sound.Dispose(); } } }
public void ConvertAudio(string filename, SoundInput input) { var source_format = input.SourceFormat; if (CommonAudioFormats.Contains(source_format)) { var output_name = Path.ChangeExtension(filename, source_format); using (var output = CreateNewFile(output_name)) { input.Source.Position = 0; input.Source.CopyTo(output); } } else { var output_name = Path.ChangeExtension(filename, "wav"); using (var output = CreateNewFile(output_name)) AudioFormat.Wav.Write(input, output); } }
public override void RequestProcessing(int samples) { var inputData = new float[samples]; SoundInput.Read(inputData, 0, inputData.Length); double[] levelData = null; if (CvInput.IsConnected) { levelData = new double[samples]; CvInput.Read(levelData, 0, levelData.Length); } for (var i = 0; i < samples; i++) { inputData[i] = (float)(inputData[i] * Math.Max(0.0, Math.Min(1.0, levelData?[i] ?? Level))); } SoundOutput.Write(inputData, 0, inputData.Length); }
public static void ConvertAudio(string entry_name, SoundInput input) { string source_format = input.SourceFormat; if (GarConvertMedia.CommonAudioFormats.Contains(source_format)) { string output_name = FindUniqueFileName(entry_name, source_format); using (var output = ArchiveFormat.CreateFile(output_name)) { input.Source.Position = 0; input.Source.CopyTo(output); } } else { string output_name = FindUniqueFileName(entry_name, "wav"); using (var output = ArchiveFormat.CreateFile(output_name)) AudioFormat.Wav.Write(input, output); } }
public override void Write(SoundInput source, Stream output) { using (var buffer = new BinaryWriter (output, Encoding.ASCII, true)) { uint total_size = (uint)(0x2e - 8 + source.PcmSize); buffer.Write (Signature); buffer.Write (total_size); buffer.Write (0x45564157); // 'WAVE' buffer.Write (0x20746d66); // 'fmt ' buffer.Write (0x12); buffer.Write (source.Format.FormatTag); buffer.Write (source.Format.Channels); buffer.Write (source.Format.SamplesPerSecond); buffer.Write (source.Format.AverageBytesPerSecond); buffer.Write (source.Format.BlockAlign); buffer.Write (source.Format.BitsPerSample); buffer.Write ((ushort)0); buffer.Write (0x61746164); // 'data' buffer.Write ((uint)source.PcmSize); source.Position = 0; source.CopyTo (output); } }
public void StopActiveProcesses() { SoundInput.StopMicrophoneInputSafely(); LightProcessingRandom.StopUpdates(); }
public void StopActiveProcesses() { SoundInput.StopMicrophoneInputSafely(); UnselectedRandom(); }
private async void SaveZeroActivated() { PartyUIUpdater.GiveVariablesSlider <PartyControlSimple, PartyControlSimple>(this, null); await SoundInput.StartMicrophoneInputSafely(); }
public override void Write(SoundInput source, Stream output) { throw new System.NotImplementedException ("EdimFormat.Write not implemenented"); }
//Microphone input private async void SelectedMicrophoneInput() { GiveMicrophoneInputSlidersVariables(); await SoundInput.StartMicrophoneInputSafely(); }
public override void Write(SoundInput source, Stream output) { using (var wav = new XoredStream(output, 0x21, true)) using (var zstream = new ZLibStream(wav, CompressionMode.Compress, CompressionLevel.Level9)) base.Write(source, zstream); }
public override void Write(SoundInput source, Stream output) { throw new System.NotImplementedException("EogFormat.Write not implemenented"); }
private void SaveZeroDeactivated() { SoundInput.StopMicrophoneInputSafely(); PartyUIUpdater.GiveVariablesInterval <PartyControlSimple, PartyControlSimple>(null, null); }