private void WaveSource_RecordingStopped(object sender, StoppedEventArgs e) { if (PassingThrough) { WaveSource.StartRecording(); } }
public Tuple <MasterAdapter, List <Fader>, CancellationTokenSource, Task> RenderProject(int startTick) { var source = new CancellationTokenSource(); var items = new List <RenderItem>(); var faders = new List <Fader>(); foreach (var track in project.tracks) { var trackItems = PrepareTrack(track, project, startTick).ToArray(); var sources = trackItems.Select(item => { var waveSource = new WaveSource(item.PosMs, item.DurMs, item.Envelope, item.SkipOver); item.OnComplete = data => waveSource.SetWaveData(data); return(waveSource); }).ToList(); sources.AddRange(project.parts .Where(part => part is UWavePart && part.trackNo == track.TrackNo) .Select(part => part as UWavePart) .Select(part => { var waveSource = new WaveSource( project.TickToMillisecond(part.position), project.TickToMillisecond(part.Duration), null, part.skipMs); if (part.Samples != null) { waveSource.SetSamples(part.Samples); } return(waveSource); })); var trackMix = new WaveMix(sources); items.AddRange(trackItems); var fader = new Fader(trackMix); fader.Scale = PlaybackManager.DecibelToVolume(track.Volume); faders.Add(fader); } items = items.OrderBy(item => item.PosMs).ToList(); int threads = Util.Preferences.Default.PrerenderThreads; var progress = new Progress(items.Count); var task = Task.Run(() => { var progress = new Progress(items.Count); Parallel.ForEach(source: items, parallelOptions: new ParallelOptions() { MaxDegreeOfParallelism = threads }, body: item => { if (source.Token.IsCancellationRequested) { return; } item.progress = progress; Resample(item); }); ReleaseSourceTemp(); progress.Clear(); }); var master = new MasterAdapter(new WaveMix(faders)); master.SetPosition((int)(project.TickToMillisecond(startTick) * 44100 / 1000)); return(Tuple.Create(master, faders, source, task)); }
/// <summary> /// /// </summary> /// <param name="source"></param> /// <param name="xrayWaveLength"></param> /// <param name="xrayElementNumber"></param> /// <param name="xrayLine"></param> /// <param name="electronAccVoltage"></param> public WaveProperty(WaveSource source, double xrayWaveLength, int xrayElementNumber, XrayLine xrayLine, double electronAccVoltage) { Source = source; WaveLength = xrayWaveLength; XrayElementNumber = xrayElementNumber; XrayLine = xrayLine; Energy = electronAccVoltage; }
public void Update() { for (int i = 0; i < bands.Count; i += 1) { WaveSource source = Global.Instance().Audio.GetWaveSource(); bands[i].GetComponent <RectTransform>().localScale = new Vector3(1f, source.GetBand(i) * 5.0f); } }
public void Update() { WaveSource source = Global.Instance().Audio.GetWaveSource(); float val = useHighBand ? source.GetHighBand() : source.GetLowBand(); Sprite sprite = val < thresh ? frame0 : frame1; GetComponent <SpriteRenderer>().sprite = sprite; }
public void StopRecording() { if (!_isRecording) { return; } _isRecording = false; WaveSource.StopRecording(); }
public void StartRecording() { if (_isRecording) { return; } _isRecording = true; WaveSource.StartRecording(); }
WaveSource getConfiguredWaveSource() { WaveSource newSource = new WaveSource(); newSource.xWaveFrequency = XWaveFrequency; newSource.zWaveFrequency = ZWaveFrequency; newSource.smoothness = Smoothness; newSource.value4 = value4; newSource.value5 = value5; newSource.value6 = value6; newSource.value7 = value7; newSource.value8 = value8; return(newSource); }
public List <WaveMix> RenderTracks() { List <WaveMix> result = new List <WaveMix>(); foreach (var track in project.tracks) { var items = PrepareTrack(track, project, 0); var progress = new Progress(items.Count()); var mix = new WaveMix(items.Select(item => { var waveSource = new WaveSource(item.PosMs, item.DurMs, item.Envelope, item.SkipOver); item.progress = progress; item.OnComplete = data => waveSource.SetWaveData(data); Resample(item); return(waveSource); })); progress.Clear(); result.Add(mix); } return(result); }
public WaveProperty(WaveSource source, double value, bool isEnergy = true) { Source = source; XrayElementNumber = -1; if (isEnergy) { Energy = value; if (source == WaveSource.Xray) { WaveLength = UniversalConstants.Convert.EnergyToXrayWaveLength(Energy); XrayElementNumber = 0; } else if (source == WaveSource.Electron) { WaveLength = UniversalConstants.Convert.EnergyToElectronWaveLength(Energy / 1000); } else if (source == WaveSource.Neutron) { WaveLength = UniversalConstants.Convert.EnergyToNeutronWaveLength(Energy); } } else { WaveLength = value; if (source == WaveSource.Xray) { Energy = UniversalConstants.Convert.WavelengthToXrayEnergy(WaveLength); XrayElementNumber = 0; } else if (source == WaveSource.Electron) { Energy = UniversalConstants.Convert.WaveLengthToElectronEnergy(WaveLength) * 1000; } else if (source == WaveSource.Neutron) { Energy = UniversalConstants.Convert.WaveLengthToNeutronEnergy(WaveLength); } } }
public void Dispose() { try { if (WaveSource != null) { WaveSource.StopRecording(); WaveSource.Dispose(); } if (WaveOutput != null) { WaveOutput.Stop(); WaveOutput.Dispose(); } if (DirectSoundOutput != null) { DirectSoundOutput.Stop(); DirectSoundOutput.Dispose(); } } catch (Exception) { } }
public void StartPassingThrough() { if (DateTime.Now <= LastPauseOrStart.AddMilliseconds(500)) { return; } LastPauseOrStart = DateTime.Now; try { WaveSource.StartRecording(); if (WaveOutput != null) { WaveOutput.Play(); } if (DirectSoundOutput != null) { DirectSoundOutput.Play(); } PassingThrough = true; } catch (Exception) { } }
public WaveProperty(int xrayElementNumber, XrayLine xrayLine) { Source = WaveSource.Xray; WaveLength = AtomConstants.CharacteristicXrayWavelength(xrayElementNumber, xrayLine); Energy = AtomConstants.CharacteristicXrayWavelength(xrayElementNumber, xrayLine); }
public WaveProperty(WaveSource source, double energy, double monochromaticity, double convergence, bool isEnergy = true) : this(source, energy, isEnergy) { Monochromaticity = monochromaticity; Convergence = convergence; }
public void MakeLink(GameObject connectTo, WaveSource waveSource, AudioLink origin) { if (this.gameObject.GetComponent <WaveGenerator>() != null) { gen = this.gameObject.GetComponent <WaveGenerator>(); genGO = this.gameObject; //Debug.Log("Adding from WaveGenerator\n" + this.gameObject.GetComponent<WaveGenerator>().waveGO); GameObject waveform = Instantiate(this.gameObject.GetComponent <WaveGenerator>().waveGO, this.transform); waveform.GetComponent <AudioPathTrack>().addStep(this.gameObject); waveform.GetComponent <changeWave>().KillListen(this.gameObject.GetComponent <WaveGenerator>()); waveform.GetComponent <changeWave>().origionalSpawn = this; //Debug.Log(waveform); players.Add(waveform); } else if (this.gameObject.GetComponent <AudioMixer>() != null) { // Debug.Log("Adding from AudioMixer\n" + this.gameObject.GetComponent<AudioMixer>().players); gen = this.gameObject.GetComponent <AudioMixer>(); genGO = this.gameObject; players = this.gameObject.GetComponent <AudioMixer>().players; foreach (GameObject pl in players) { pl.GetComponent <AudioPathTrack>().addStep(genGO); } } else if (this.gameObject.GetComponent <HighPass>() != null) { gen = this.gameObject.GetComponent <HighPass>(); genGO = this.gameObject; players = this.gameObject.GetComponent <HighPass>().players; foreach (GameObject pl in players) { pl.GetComponent <AudioPathTrack>().addStep(genGO); } } else if (this.gameObject.GetComponent <LowPass>() != null) { gen = this.gameObject.GetComponent <LowPass>(); genGO = this.gameObject; players = this.gameObject.GetComponent <LowPass>().players; foreach (GameObject pl in players) { pl.GetComponent <AudioPathTrack>().addStep(genGO); } } connected = connectTo; if (connected.GetComponent <AudioOut>() != null) { //Debug.Log("Players has " + players.Count + " GameObjects"); for (int i = 0; i < players.Count; ++i) { players[i].GetComponent <changeWave>().listenFreq(players[i].GetComponent <changeWave>().origionalSpawn); players[i].GetComponent <AudioSource>().Play(); } } else if (connected.GetComponent <AudioMixer>() != null) { //Debug.Log("Players has " + players.Count + " GameObjects"); AudioMixer dest = connected.GetComponent <AudioMixer>(); dest.NewConnection(gen, players); } else if (connected.GetComponent <HighPass>()) { connected.GetComponent <HighPass>().NewConnection(gen, players); } else if (connected.GetComponent <LowPass>()) { connected.GetComponent <LowPass>().NewConnection(gen, players); } foreach (GameObject p in players) { p.transform.parent = connectTo.transform; p.transform.localPosition = Vector3.zero; } if (connected.GetComponent <AudioLink>() != null) { connected.GetComponent <AudioLink>().updateLink.Invoke(origin); } connecting.Invoke(connectTo, waveSource); dist = Vector3.Distance(this.gameObject.transform.position, connected.transform.position); }
void ISynthesizer.SetUp() { using (WavePlayer player = WavePlayer.CreateWavePlayer()) { } AudioGraphSettings settings = new AudioGraphSettings(AudioRenderCategory.Media) { //QuantumSizeSelectionMode = QuantumSizeSelectionMode.LowestLatency }; AudioGraph.CreateAsync(settings).AsTask().ContinueWith(graphTask => { CreateAudioGraphResult graphResult = graphTask.Result; if(graphResult.Status != AudioGraphCreationStatus.Success) { this.EmitFailed(); } else { graphResult.Graph.CreateDeviceOutputNodeAsync().AsTask().ContinueWith(nodeTask => { CreateAudioDeviceOutputNodeResult nodeResult = nodeTask.Result; if(nodeResult.Status != AudioDeviceNodeCreationStatus.Success) { this.EmitFailed(); } else { _audioGraph = graphResult.Graph; _frameInputNode = _audioGraph.CreateFrameInputNode(); _frameInputNode.AddOutgoingConnection(nodeResult.DeviceOutputNode); _frameInputNode.QuantumStarted += this.OnQuantumStarted; _channelsNumber = _audioGraph.EncodingProperties.ChannelCount; _waveSource = new WaveSource(_audioGraph.EncodingProperties.SampleRate, _channelsNumber); this.EmitReady(); } }); } }); }