void Start() { tolerance = Game.level == 0 ? 10f : 13f; audioSource = GetComponent<AudioSource>(); lastItemTime = new float[bands]; lastCuredSpectrum = new float[bands]; if (!equalizer) equalizer = GameObject.FindWithTag ("Equalizer").GetComponent<Equalizer>(); equalizer.audioSource = this.audioSource; itemSize = (Game.WorldSize.x * 2f) / bands; }
async Task setPreset(EqualizerPreset preset) { try { if (CurrentItem == null) { Equalizer.Shared.CurrentPreset = preset; } else { #if iPod Equalizer.SaveEq(currentItem, preset); if (CurrentItem == AudioPlayer.Shared.CurrentSong) { await Equalizer.Shared.ApplyEqualizer(); } #else Equalizer.Shared.ApplyEqualizer(); #endif } SetSourc(); if (PresetSelected != null) { PresetSelected(preset); } #if PIONEER if (PPioneerManager.SharedPioneerManager.Connected) { NavigationController.PopViewController(true); } else #endif this.NavigationController.DismissViewController(true, null); } catch (Exception ex) { LogManager.Shared.Report(ex); } //TableView.ReloadData (); }
public static XAMUmpMessageTelegram Create(byte volume, Equalizer eq, XAMUmpPlayFlags playFlags, short incVolumeTime, short sequenceID, short bytesPerFrame, int delayBetweenFrames, string IpAdr, string AMSNetIp, TraceDelegate trace) { List <byte> d = new List <byte>(); if (volume > 100) { volume = 100; } d.Add((byte)volume); // Volume 100 = maximum d.Add((byte)eq); // equalizer 0 = normal byte[] pf = playFlags.GetBytes(); d.Add(pf[0]); // playfalsgs 2 00001 = ignore AMSNetID d.Add(pf[1]); // playfalsgs 0 d.AddRange(BitConverter.GetBytes(incVolumeTime)); // inc volume time d.AddRange(BitConverter.GetBytes(sequenceID)); d.AddRange(BitConverter.GetBytes(bytesPerFrame)); // bytes per frame 882 = default d.Add((byte)0); // reserved d.Add((byte)0); // reserved d.AddRange(BitConverter.GetBytes((Int32)delayBetweenFrames)); // delay between frames byte[] ip = IPAddress.Parse(IpAdr).GetAddressBytes(); d.Add(ip[0]); // ip address // 255.255.255.255 = exapt all d.Add(ip[1]); // ip address // 255.255.255.255 = exapt all d.Add(ip[2]); // ip address // 255.255.255.255 = exapt all d.Add(ip[3]); // ip address // 255.255.255.255 = exapt all byte[] ams = IPAddress.Parse(AMSNetIp).GetAddressBytes(); d.Add(ams[0]); // ip address // 255.255.255.255 = exapt all d.Add(ams[1]); // ip address // 255.255.255.255 = exapt all d.Add(ams[2]); // ip address // 255.255.255.255 = exapt all d.Add(ams[3]); // ip address // 255.255.255.255 = exapt all d.Add((byte)1); // AMSnetID d.Add((byte)1); // AMSnetID d.Add((byte)0); // reserved d.Add((byte)0); // reserved // set audio play remote return(new XAMUmpMessageTelegram(UmpMessageID.AudioPlayRemote, 0, d.ToArray(), trace)); }
public void Open(string filename) { CleanupPlayback(); var source = CodecFactory.Instance.GetCodec(filename); volumeSource = new VolumeSource(source); equalizer = Equalizer.Create10BandEqualizer(volumeSource); finalSource = equalizer .ToStereo() .ChangeSampleRate(44100) .AppendSource(Equalizer.Create10BandEqualizer, out equalizer) .ToWaveSource(16); if (WasapiOut.IsSupportedOnCurrentPlatform) { soundOut = new WasapiOut() { Latency = 100, Device = PlaybackDevice } } ; else { soundOut = new DirectSoundOut(); } soundOut.Initialize(finalSource); soundOut.Volume = deviceVolume; if (this.OpenCompleted != null) { this.OpenCompleted(this, new EventArgs()); } }
public void TestFlatten() { EventWaitHandle waitHandle = new AutoResetEvent(false); using (MemoryStream stream = new MemoryStream()) using (SpeechSynthesizer synth = new SpeechSynthesizer()) { synth.SetOutputToWaveStream(stream); synth.Speak("This is a test for flattening"); stream.Seek(0, SeekOrigin.Begin); IWaveSource source = new WaveFileReader(stream); Equalizer equalizer = Equalizer.Create10BandEqualizer(source); equalizer.SampleFilters[0].SetGain(-9.6f); equalizer.SampleFilters[1].SetGain(-9.6f); equalizer.SampleFilters[2].SetGain(-9.6f); equalizer.SampleFilters[3].SetGain(-3.9f); equalizer.SampleFilters[4].SetGain(2.4f); equalizer.SampleFilters[5].SetGain(11.1f); equalizer.SampleFilters[6].SetGain(15.9f); equalizer.SampleFilters[7].SetGain(15.9f); equalizer.SampleFilters[8].SetGain(15.9f); equalizer.SampleFilters[9].SetGain(16.7f); var soundOut = new WasapiOut(); soundOut.Stopped += (s, e) => waitHandle.Set(); soundOut.Initialize(equalizer.ToWaveSource()); soundOut.Play(); waitHandle.WaitOne(); soundOut.Dispose(); equalizer.Dispose(); source.Dispose(); } }
public override IEnumerator <FileItem> GetEnumerator() { if (formProcessing != null) { formProcessing.Close(); } formProcessing = new FormProcessing(); formProcessing.Show(); formProcessing.Update(); formProcessing.ShowLogMessage("Start generating.", IconKey.Start); List <FileItem> list = new List <FileItem>(); try { formProcessing.ShowLogMessage("Getting database schema.", IconKey.Schema); formProcessing.Cursor = Cursors.WaitCursor; Mapping newMapping = MappingFactory.CreateMapping(this.InputFilePath, this.InputFileContents); Mapping oldMapping = GetLocalMapping(newMapping); formProcessing.Cursor = Cursors.Default; formProcessing.ShowLogMessage("Generating mapping.", IconKey.Dbsx); list.Add(new FileItem(this.MappingName, ItemType.CacheSettingTemplate, !Equalizer.IsEqual(oldMapping.DataAccessNamespaces, newMapping.DataAccessNamespaces))); list.Add(new FileItem(this.MappingName, ItemType.ConnectionStrings, !Equalizer.IsEqual(oldMapping.ConnectionStringName, newMapping.ConnectionStringName))); list.Add(new FileItem(this.MappingName, ItemType.Document, !Equalizer.IsEqual(oldMapping.Database, newMapping.Database))); list.Add(new FileItem(this.MappingName, ItemType.Enums, !Equalizer.IsEqual(oldMapping.Enums, newMapping.Enums))); foreach (ModelNamespace ns in newMapping.ModelNamespaces) { if (ns.Models.Count > 0) { if (oldMapping.ModelNamespaces.Contains(ns.Name)) { list.Add(new FileItem(this.MappingName, ns.Name, ItemType.Models, !Equalizer.IsEqual(oldMapping.ModelNamespaces[ns.Name], ns))); } else { list.Add(new FileItem(this.MappingName, ns.Name, ItemType.Models, true)); } } } foreach (DataAccessNamespace ns in newMapping.DataAccessNamespaces) { if (ns.DataAccesses.Count > 0) { if (oldMapping.DataAccessNamespaces.Contains(ns.Name)) { list.Add(new FileItem(this.MappingName, ns.Name, ItemType.DataAccess, !Equalizer.IsEqual(oldMapping.DataAccessNamespaces[ns.Name], ns))); } else { list.Add(new FileItem(this.MappingName, ns.Name, ItemType.DataAccess, true)); } } } mappingContent = Serializer.Serialize(newMapping); generatedSuccessfully = true; processBarStep = (100 - formProcessing.progressBarGenerating.Value) / list.Count; } catch (Exception ex) { formProcessing.Cursor = Cursors.Default; base.LogException(ex); mappingContent = ex.Message; generatedSuccessfully = false; formProcessing.ShowLogMessage("Error: " + ex.Message, IconKey.Error); list.Clear(); } return(list.GetEnumerator()); }
private void CheckBoxEffectsEqualizerAntialiasingTurn_Checked(object sender, RoutedEventArgs e) { Equalizer.turnAntialiasing(); }
private void CheckBoxEffectsEqualizerStaticVolumeTurn_UnChecked(object sender, RoutedEventArgs e) { Equalizer.turnVolume(); this.GroupBoxEffectsEqualizerColumnsSettings.Visibility = Visibility.Visible; this.GroupBoxEffectsEqualizerStaticVolumeSettings.Visibility = Visibility.Hidden; }
public async Task <bool> OpenTrack(IPlaySource track, bool openCrossfading, long position) { IsLoading = true; if (!openCrossfading) { StopPlayback(); } if (_crossfadeService.IsFading) { _crossfadeService.Cancel(); } if (_soundSource != null && !openCrossfading) { _soundSource.Dispose(); } if (openCrossfading && _soundSource != null) { _soundOut.Stopped -= SoundOut_Stopped; _loopStream.StreamFinished -= LoopStream_StreamFinished; _simpleNotificationSource.BlockRead -= SimpleNotificationSource_BlockRead; _crossfadeService.CrossfadeOut(_soundOut, CrossfadeDuration).Forget(); _soundOut = null; } var tempSource = await GetSoundSource(track, position); if (tempSource == null) { return(false); } _soundSource = tempSource; if (_soundSource.WaveFormat.SampleRate < 44100) //Correct sample rate { _soundSource = _soundSource.ChangeSampleRate(44100); } _soundSource = _soundSource .AppendSource(x => new LoopStream(x), out _loopStream) .AppendSource(x => Equalizer.Create10BandEqualizer(x.ToSampleSource()), out _equalizer) .AppendSource(x => new SimpleNotificationSource(x) { Interval = 100 }, out _simpleNotificationSource) .ToWaveSource(); _loopStream.EnableLoop = IsLooping; _loopStream.StreamFinished += LoopStream_StreamFinished; _simpleNotificationSource.BlockRead += SimpleNotificationSource_BlockRead; for (var i = 0; i < EqualizerBands.Count; i++) { SetEqualizerBandValue(EqualizerBands.Bands[i].Value, i); } if (_soundOut == null) { _soundOut = _soundOutProvider.GetSoundOut(); _soundOut.Stopped += SoundOut_Stopped; } _soundOut.Initialize(_soundSource); _soundOut.Volume = Volume; IsLoading = false; OnTrackLengthChanged(); _playTimeStopwatch.Reset(); if (openCrossfading) { await TogglePlayPause(); _fadingService.FadeIn(_soundOut, Volume).Forget(); } CurrentStateChanged(); OnPositionChanged(); return(true); }
public void SetEqualizer(VLCEqualizer vlcEq) { var eq = new Equalizer(vlcEq.Index); MediaPlayer?.setEqualizer(eq); }
public void SetEqualizer(Equalizer equalizer) { if (equalizer == null) { LibVlcMethods.libvlc_media_player_set_equalizer(MHMediaPlayer, IntPtr.Zero); return; } LibVlcMethods.libvlc_media_player_set_equalizer(MHMediaPlayer, equalizer.Handle); }
private void Awake() { equalizer = Equalizer.Instance; tester = AITester.Instance; saveAndLoadLevel = SaveAndLoadLevel.Instance; }
async void SetSourc() { #if iPod source.Default = await Equalizer.GetDefault(currentItem) ?? Equalizer.Shared.CurrentPreset; source.Current = currentItem == null ? Equalizer.Shared.CurrentPreset : await Equalizer.GetPreset(currentItem); #else source.Current = Equalizer.Shared.CurrentPreset; #endif TableView.ReloadData(); }
private List <FileItem> GetFileItems(Mapping newMapping, Mapping oldMapping) { List <FileItem> list = new List <FileItem>(); try { list.Add(new FileItem(this.mappingName, FileItemType.CacheSettingTemplate, this.firstRunOfThisGeneratorVersion || oldMapping == null || !Equalizer.IsEqual(oldMapping.DataAccessNamespaces, newMapping.DataAccessNamespaces))); list.Add(new FileItem(this.mappingName, FileItemType.ConnectionStrings, this.firstRunOfThisGeneratorVersion || oldMapping == null || !Equalizer.IsEqual(oldMapping.ConnectionStringName, newMapping.ConnectionStringName))); list.Add(new FileItem(this.mappingName, FileItemType.Document, this.firstRunOfThisGeneratorVersion || oldMapping == null || !Equalizer.IsEqual(oldMapping.Database, newMapping.Database))); foreach (ModelNamespace ns in newMapping.ModelNamespaces) { if (ns.Models.Count > 0) { if (oldMapping != null && oldMapping.ModelNamespaces.Contains(ns.Name)) { list.Add(new FileItem(this.mappingName, ns.Name, FileItemType.Models, this.firstRunOfThisGeneratorVersion || !Equalizer.IsEqual(oldMapping.ModelNamespaces[ns.Name], ns))); } else { list.Add(new FileItem(this.mappingName, ns.Name, FileItemType.Models, true)); } } } foreach (DataAccessNamespace ns in newMapping.DataAccessNamespaces) { if (ns.DataAccesses.Count > 0) { if (oldMapping != null && oldMapping.DataAccessNamespaces.Contains(ns.Name)) { list.Add(new FileItem(this.mappingName, ns.Name, FileItemType.DataAccess, this.firstRunOfThisGeneratorVersion || !Equalizer.IsEqual(oldMapping.DataAccessNamespaces[ns.Name], ns))); } else { list.Add(new FileItem(this.mappingName, ns.Name, FileItemType.DataAccess, true)); } } } progressStep = (100 - progress) / list.Count; progress += progressStep; if (ProgressChanged != null) { ProgressChanged(progress); } } catch (Exception ex) { ExceptionThrown(ex); //mappingContent = ex.Message; list.Clear(); } return(list); }
public EqualizerService() { mediaPlayer = AudioPlayerService.Instance; equalizer = new Equalizer(0, mediaPlayer.AudioSessionId); equalizer.SetEnabled(true); }
private void Awake() { Instance = this; frequencyMap = new Dictionary <float, float>(); spectrum = new float[Equalizer.Instance.sampleRate]; }
public EqualizerChangedEventArgs(int filterIndex, float value, Equalizer equalizer) { EqFilterEntry filter = equalizer.SampleFilters[filterIndex]; filter.SetGain(value); }
public void OpenFile(string path) { Stop(); if (ActiveStream != null) { sampleReset = 0; SelectionBegin = TimeSpan.Zero; SelectionEnd = TimeSpan.Zero; ChannelPosition = 0; } StopAndCloseStream(); if (System.IO.File.Exists(path)) { try { waveOutDevice = new WaveOutEvent() { DesiredLatency = 100 }; this.inputStream = new AudioFileReaderRB(path); this.ActiveStream = this.inputStream.ReaderStream; sampleAggregator = new SampleAggregator(fftDataSize); Equalizer eq = new Equalizer(inputStream, this.bands); eq.Sample += eq_Sample; waveOutDevice.Init(eq); ChannelLength = inputStream.TotalTime.TotalSeconds; FileTag = TagLib.File.Create(path); //GenerateWaveformData(path); CanPlay = true; } catch { ActiveStream = null; CanPlay = false; } } }
public async Task <bool> OpenTrack(PlayableBase track) { if (!IsEnabled) { OnSoundOutErrorOccurred(Application.Current.Resources["NoSoundOutDeviceFound"].ToString()); return(false); } _playAfterLoading = false; IsLoading = true; StopPlayback(); if (CurrentTrack != null) { CurrentTrack.IsOpened = false; CurrentTrack.Unload(); } if (SoundSource != null && !_crossfade.IsCrossfading) { SoundSource.Dispose(); } track.IsOpened = true; CurrentTrack = track; var t = Task.Run(() => track.Load()); Equalizer equalizer; var result = await SetSoundSource(track); switch (result.State) { case State.False: track.IsOpened = false; return(false); case State.Exception: track.IsOpened = false; IsLoading = false; CurrentTrack = null; if (ExceptionOccurred != null) { ExceptionOccurred(this, (Exception)result.CustomState); } StopPlayback(); return(false); } if (Settings.SampleRate == -1 && SoundSource.WaveFormat.SampleRate < 44100) { SoundSource = SoundSource.ChangeSampleRate(44100); } else if (Settings.SampleRate > -1) { SoundSource = SoundSource.ChangeSampleRate(Settings.SampleRate); } SoundSource = SoundSource .AppendSource(x => Equalizer.Create10BandEqualizer(x.ToSampleSource()), out equalizer) .AppendSource(x => new SingleBlockNotificationStream(x), out _singleBlockNotificationStream) .AppendSource(x => new SimpleNotificationSource(x) { Interval = 100 }, out _simpleNotificationSource) .ToWaveSource(Settings.WaveSourceBits); MusicEqualizer = equalizer; SetAllEqualizerSettings(); _simpleNotificationSource.BlockRead += notifysource_BlockRead; _singleBlockNotificationStream.SingleBlockRead += notificationSource_SingleBlockRead; _analyser = new SampleAnalyser(FFTSize); _analyser.Initialize(SoundSource.WaveFormat); try { _soundOut.Initialize(SoundSource); } catch (Exception ex) { track.IsOpened = false; IsLoading = false; OnSoundOutErrorOccurred(ex.Message); return(false); } OnPropertyChanged("TrackLength"); OnPropertyChanged("CurrentTrackLength"); CurrentStateChanged(); _soundOut.Volume = Volume; if (StartVisualization != null) { StartVisualization(this, EventArgs.Empty); } track.LastTimePlayed = DateTime.Now; if (_crossfade.IsCrossfading) { _fader.CrossfadeIn(_soundOut, Volume); } IsLoading = false; if (_playAfterLoading) { TogglePlayPause(); } await t; return(true); }
void Start() { client = (DataController)GameObject.Find("ThinkGear").GetComponent(typeof(DataController)); eq = (Equalizer)GameObject.Find("Equalizer").GetComponent(typeof(Equalizer)); string path = ""; // store the song data in different locations depending on the platform if(Application.platform == RuntimePlatform.WindowsPlayer){ path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); path = System.IO.Path.Combine(path, "NeuroSky"); path = System.IO.Path.Combine(path, "Brainwave Visualizer"); } else { path = Environment.GetFolderPath(Environment.SpecialFolder.Personal); path = System.IO.Path.Combine(path, "Library/Application Support/NeuroSky/Brainwave Visualizer"); } // make sure the data directory exists before using it if(!System.IO.Directory.Exists(path)) System.IO.Directory.CreateDirectory(path); UserStatus.dataPath = path; }
protected override IWaveSource GetSource() { var source = GetMockSource(); return(Equalizer.Create10BandEqualizer(source.ToSampleSource()).ToWaveSource()); }
public EqualizerViewModel(Equalizer equalizer) { this.Equalizer = equalizer; }
public async Task ApplyEqualizer(AVPlayerItem item) { #if iPod var curEq = await Equalizer.GetPreset(AudioPlayer.Shared.CurrentSong) ?? await Equalizer.GetDefault(AudioPlayer.Shared.CurrentSong) ?? Equalizer.Shared.CurrentPreset; Equalizer.Shared.ApplyPreset(curEq); Equalizer.Shared.CurEqId = curEq.GlobalId; #endif ApplyEqualizer(Equalizer.Shared.Bands, item); }
/// <summary> /// Create a custom EQ curve from a source stored as an Equalier. /// </summary> public Custom(Equalizer eq) => this.eq = eq;