private void HandleMessage(DOMEvent e) { var data = e.As <MessageEvent>().data; var cmd = data.Member("cmd").As <string>(); switch (cmd) { case "load": Load(data.Member("data"), data.Member("indexes").As <int[]>()); break; case "invalidate": _renderer.Invalidate(); break; case "resize": _renderer.Resize(data.Member("width").As <int>()); break; case "tex": Tex(data.Member("data").As <string>()); break; case "renderMultiple": RenderMultiple(data.Member("data").As <int[]>()); break; case "updateSettings": UpdateSettings(data.Member("settings")); break; } }
private void HandleWorkerMessage(DOMEvent e) { var data = e.As <MessageEvent>().data; var cmd = data.Member("cmd").As <string>(); switch (cmd) { case "alphaTab.preRender": OnPreRender(data.Member("result").As <RenderFinishedEventArgs>()); break; case "alphaTab.partialRenderFinished": OnPartialRenderFinished(data.Member("result").As <RenderFinishedEventArgs>()); break; case "alphaTab.renderFinished": OnRenderFinished(data.Member("result").As <RenderFinishedEventArgs>()); break; case "alphaTab.postRenderFinished": BoundsLookup = BoundsLookup.FromJson(data.Member("boundsLookup"), _api.Score); OnPostRenderFinished(); break; case "alphaTab.error": OnError(data.Member("type").As <string>(), data.Member("detail").As <Exception>()); break; } }
private void HandleWorkerMessage(DOMEvent e) { var data = e.As<MessageEvent>().data; var cmd = data.Member("cmd").As<string>(); switch (cmd) { case "alphaTab.preRender": OnPreRender(data.Member("result").As<RenderFinishedEventArgs>()); break; case "alphaTab.partialRenderFinished": OnPartialRenderFinished(data.Member("result").As<RenderFinishedEventArgs>()); break; case "alphaTab.renderFinished": OnRenderFinished(data.Member("result").As<RenderFinishedEventArgs>()); break; case "alphaTab.postRenderFinished": BoundsLookup = BoundsLookup.FromJson(data.Member("boundsLookup"), Score); OnPostRenderFinished(); break; case "alphaTab.error": console.error(data.Member("exception")); break; case "alphaTab.loaded": var score = data.Member("score").As<Score>(); if (score.As<bool>()) { var jsonConverter = new JsonConverter(); score = jsonConverter.JsObjectToScore(score); } Score = score; OnLoaded(score); break; } }
private void HandleMessage(DOMEvent e) { var data = e.As <MessageEvent>().data; var cmd = data.Member("cmd").As <string>(); switch (cmd) { case "alphaTab.initialize": var settings = Settings.FromJson(data.Member("settings"), null); _renderer = new ScoreRenderer(settings); _renderer.PartialRenderFinished += result => PostMessage(new { cmd = "alphaTab.partialRenderFinished", result = result }); _renderer.RenderFinished += result => PostMessage(new { cmd = "alphaTab.renderFinished", result = result }); _renderer.PostRenderFinished += () => PostMessage(new { cmd = "alphaTab.postRenderFinished", boundsLookup = _renderer.BoundsLookup.ToJson() }); _renderer.PreRender += result => PostMessage(new { cmd = "alphaTab.preRender", result = result }); break; case "alphaTab.load": Load(data.Member("data"), data.Member("indexes").As <int[]>()); break; case "alphaTab.invalidate": _renderer.Invalidate(); break; case "alphaTab.resize": _renderer.Resize(data.Member("width").As <int>()); break; case "alphaTab.tex": Tex(data.Member("data").As <string>()); break; case "alphaTab.renderMultiple": RenderMultiple(data.Member("data").As <int[]>()); break; case "alphaTab.score": var converter = new JsonConverter(); var score = converter.JsObjectToScore(data.Member("score").As <Score>()); Score = score; break; case "alphaTab.updateSettings": UpdateSettings(data.Member("settings")); break; } }
private void HandleMessage(DOMEvent e) { var data = e.As <MessageEvent>().data; var cmd = data.Member("cmd").As <string>(); switch (cmd) { case "load": Load(data.Member("data"), data.Member("indexes").As <int[]>()); break; case "tex": Tex(data.Member("data").As <string>()); break; case "renderMultiple": RenderMultiple(data.Member("data").As <int[]>()); break; } }
private void HandleMessage(DOMEvent e) { var data = e.As <MessageEvent>().data; var cmd = data.Member("cmd").As <string>(); switch (cmd) { case "playerSampleRequest": OnSampleRequest(); break; case "playerFinished": OnFinished(); break; case "playerPositionChanged": OnPositionChanged(data.Member("pos").As <int>()); break; } }
private void HandleMessage(DOMEvent e) { var data = e.As <MessageEvent>().data; var cmd = data.Member("cmd").As <string>(); switch (cmd) { case CmdOutputSampleRequest: SampleRequest(); break; case CmdOutputFinished: Finished(); break; case CmdOutputSamplesPlayed: SamplesPlayed(data.Member("samples").As <int>()); break; } }
private void HandleWorkerMessage(DOMEvent e) { var data = e.As <MessageEvent>().data; var cmd = data.Member("cmd").As <string>(); switch (cmd) { case "preRender": OnPreRender(); break; case "partialRenderFinished": OnPartialRenderFinished(data.Member("result").As <RenderFinishedEventArgs>()); break; case "renderFinished": OnRenderFinished(data.Member("result").As <RenderFinishedEventArgs>()); break; case "postRenderFinished": OnPostRenderFinished(); break; case "error": console.error(data.Member("exception")); break; case "loaded": var score = data.Member("score").As <Score>(); if (score.As <bool>()) { var jsonConverter = new JsonConverter(); score = jsonConverter.JsObjectToScore(score); } _workerApi.TriggerEvent("loaded", score); break; } }
public void HandleMessage(DOMEvent e) { var data = e.As <MessageEvent>().data; var cmd = data.Member("cmd").As <string>(); switch (cmd) { case "play": Play(); break; case "pause": Pause(); break; case "isReadyForPlay": PostMessage(new { cmd = "isReadyForPlay", value = IsReadyForPlay() }); break; case "getMasterVolume": PostMessage(new { cmd = "getMasterVolume", value = _player.MasterVolume }); break; case "setMasterVolume": _player.MasterVolume = data.Member("value").As <float>(); break; case "playPause": PlayPause(); break; case "stop": Stop(); break; case "setPositionTick": SetPositionTick(data.Member("tick").As <int>()); break; case "setPositionTime": SetPositionTime(data.Member("time").As <int>()); break; case "loadSoundFontUrl": LoadSoundFontUrl(data.Member("url").As <string>()); break; case "loadSoundFontBytes": LoadSoundFontBytes(data.Member("data").As <byte[]>()); break; case "loadMidiUrl": LoadMidiUrl(data.Member("url").As <string>()); break; case "loadMidiBytes": LoadMidiBytes(data.Member("data").As <byte[]>()); break; case "getState": PostMessage(new { cmd = "getState", value = GetState() }); break; case "isSoundFontLoaded": PostMessage(new { cmd = "isSoundFontLoaded", value = IsSoundFontLoaded() }); break; case "isMidiLoaded": PostMessage(new { cmd = "isMidiLoaded", value = IsMidiLoaded() }); break; case "setLogLevel": SetLogLevel(data.Member("level").As <LogLevel>()); break; } }
public virtual void HandleWorkerMessage(DOMEvent e) { var data = e.As <MessageEvent>().data; var cmd = data.Member("cmd").As <string>(); switch (cmd) { case AlphaSynthWebWorker.CmdReady: _workerIsReady = true; CheckReady(); break; case AlphaSynthWebWorker.CmdReadyForPlayback: _workerIsReadyForPlayback = true; CheckReadyForPlayback(); break; case AlphaSynthWebWorker.CmdPositionChanged: _timePosition = data.Member("currentTime").As <double>(); _tickPosition = data.Member("currentTick").As <int>(); TriggerEvent("positionChanged", new[] { data }); break; case AlphaSynthWebWorker.CmdPlayerStateChanged: _state = data.Member("state").As <PlayerState>(); TriggerEvent("playerStateChanged", new[] { data }); break; case AlphaSynthWebWorker.CmdFinished: TriggerEvent("finished"); break; case AlphaSynthWebWorker.CmdSoundFontLoaded: TriggerEvent("soundFontLoaded"); break; case AlphaSynthWebWorker.CmdSoundFontLoadFailed: TriggerEvent("soundFontLoadFailed"); break; case AlphaSynthWebWorker.CmdMidiLoaded: _isMidiLoaded = true; CheckReadyForPlayback(); TriggerEvent("midiFileLoaded"); break; case AlphaSynthWebWorker.CmdMidiLoadFailed: _isSoundFontLoaded = true; CheckReadyForPlayback(); TriggerEvent("midiFileLoadFailed"); break; case AlphaSynthWebWorker.CmdLog: Logger.Log(data.Member("level").As <LogLevel>(), data.Member("message").As <string>()); break; // output communication ( output <- worker ) case WebWorkerOutput.CmdOutputSequencerFinished: _output.SequencerFinished(); break; case WebWorkerOutput.CmdOutputAddSamples: _output.AddSamples(data.Member("samples").As <SampleArray>()); break; case WebWorkerOutput.CmdOutputPlay: _output.Play(); break; case WebWorkerOutput.CmdOutputPause: _output.Pause(); break; case WebWorkerOutput.CmdOutputResetSamples: _output.ResetSamples(); break; } }
public virtual void HandleWorkerMessage(DOMEvent e) { var data = e.As <MessageEvent>().data; var cmd = data.Member("cmd").As <string>(); switch (cmd) { // responses case "isReadyForPlay": case "getState": case "getMasterVolume": case "isSoundFontLoaded": case "isMidiLoaded": TriggerEvent(cmd, new[] { data.Member("value") }); break; // events case "ready": _isWorkerReady = true; CheckForReadyState(); break; case "positionChanged": TriggerEvent(cmd, new[] { data.Member("currentTime"), data.Member("endTime"), data.Member("currentTick"), data.Member("endTick") }); break; case "playerStateChanged": TriggerEvent(cmd, new[] { data.Member("state") }); break; case "finished": TriggerEvent(cmd); break; case "soundFontLoad": TriggerEvent(cmd, new[] { data.Member("loaded"), data.Member("total") }); break; case "soundFontLoaded": TriggerEvent(cmd); break; case "soundFontLoadFailed": TriggerEvent(cmd); break; case "midiLoad": TriggerEvent(cmd, new[] { data.Member("loaded"), data.Member("total") }); break; case "midiFileLoaded": TriggerEvent(cmd); break; case "midiFileLoadFailed": TriggerEvent(cmd); break; case "readyForPlay": TriggerEvent(cmd, new[] { data.Member("value") }); break; case "log": Log(data.Member("level").As <LogLevel>(), data.Member("message").As <string>()); break; // js player communication case "playerSequencerFinished": _player.SequencerFinished(); break; case "playerAddSamples": _player.AddSamples(data.Member("samples").As <SampleArray>()); break; case "playerPlay": _player.Play(); break; case "playerPause": _player.Pause(); break; case "playerStop": _player.Stop(); break; case "playerSeek": _player.Seek(data.Member("pos").As <int>()); break; } }
public void HandleMessage(DOMEvent e) { var data = e.As <MessageEvent>().data; var cmd = data.Member("cmd").As <string>(); switch (cmd) { case CmdSetLogLevel: Logger.LogLevel = data.Member("value").As <LogLevel>(); break; case CmdSetMasterVolume: _player.MasterVolume = data.Member("value").As <float>(); break; case CmdSetMetronomeVolume: _player.MetronomeVolume = data.Member("value").As <float>(); break; case CmdSetPlaybackSpeed: _player.PlaybackSpeed = data.Member("value").As <double>(); break; case CmdSetTickPosition: _player.TickPosition = data.Member("value").As <int>(); break; case CmdSetTimePosition: _player.TimePosition = data.Member("value").As <double>(); break; case CmdSetPlaybackRange: _player.PlaybackRange = data.Member("value").As <PlaybackRange>(); break; case CmdSetIsLooping: _player.IsLooping = data.Member("value").As <bool>(); break; case CmdPlay: _player.Play(); break; case CmdPause: _player.Pause(); break; case CmdPlayPause: _player.PlayPause(); break; case CmdStop: _player.Stop(); break; case CmdLoadSoundFontBytes: _player.LoadSoundFont(data.Member("data").As <byte[]>()); break; case CmdLoadMidiBytes: _player.LoadMidi(data.Member("data").As <byte[]>()); break; case CmdSetChannelMute: _player.SetChannelMute(data.Member("channel").As <int>(), data.Member("mute").As <bool>()); break; case CmdSetChannelSolo: _player.SetChannelSolo(data.Member("channel").As <int>(), data.Member("solo").As <bool>()); break; case CmdSetChannelVolume: _player.SetChannelVolume(data.Member("channel").As <int>(), data.Member("volume").As <double>()); break; case CmdSetChannelProgram: _player.SetChannelProgram(data.Member("channel").As <int>(), data.Member("program").As <byte>()); break; case CmdResetChannelStates: _player.ResetChannelStates(); break; } }