Пример #1
0
        public AlphaTabWorkerScoreRenderer(AlphaTabApi api, Settings settings)
        {
            _api = api;
            try
            {
                _worker = new Worker(settings.ScriptFile);
            }
            catch
            {
                // fallback to blob worker
                try
                {
                    HaxeString script = "importScripts('" + settings.ScriptFile + "')";
                    var        blob   = new Blob(new [] { script });
                    _worker = new Worker(URL.CreateObjectURL(blob));
                }
                catch (Exception e)
                {
                    Logger.Error("Rendering", "Failed to create WebWorker: " + e);
                    // TODO: fallback to synchronous mode
                }
            }

            _worker.PostMessage(new { cmd = "alphaTab.initialize", settings = settings.ToJson() });
            _worker.AddEventListener("message", (Action <Event>)(HandleWorkerMessage));
        }
Пример #2
0
        public AlphaSynthWebWorkerApi(ISynthOutput player, string alphaSynthScriptFile, LogLevel logLevel)
        {
            _output                = player;
            _output.Ready         += OnOutputReady;
            _output.SamplesPlayed += OnOutputSamplesPlayed;
            _output.SampleRequest += OnOutputSampleRequest;
            _output.Finished      += OnOutputFinished;

            _events = new FastDictionary <string, FastList <Delegate> >();

            _output.Open();

            try
            {
                _synth = new Worker(alphaSynthScriptFile);
            }
            catch
            {
                // fallback to blob worker
                try
                {
                    HaxeString script = "importScripts('" + alphaSynthScriptFile + "')";
                    var        blob   = new Blob(Script.Write <object>("[ script ]"));
                    _synth = new Worker(URL.CreateObjectURL(blob));
                }
                catch (Exception e)
                {
                    Logger.Error("AlphaSynth", "Failed to create WebWorker: " + e);
                    // TODO: fallback to synchronous mode
                }
            }

            _synth.AddEventListener("message", (Action <MessageEvent>)HandleWorkerMessage, false);

            _synth.PostMessage(new
            {
                cmd        = AlphaSynthWebWorker.CmdInitialize,
                sampleRate = _output.SampleRate,
                logLevel   = logLevel
            });

            MasterVolume    = 1;
            PlaybackSpeed   = 1;
            MetronomeVolume = 0;
        }
Пример #3
0
 public extern Element GetElementById(HaxeString id);
Пример #4
0
 public extern UIEvent(HaxeString type, dynamic eventInitDict);
Пример #5
0
 public extern void Write(HaxeString s);
Пример #6
0
 public extern void FillText(HaxeString text, HaxeFloat x, HaxeFloat y);
Пример #7
0
 public extern object GetContext(HaxeString contextId);
Пример #8
0
 public static extern dynamic Parse(HaxeString text);
Пример #9
0
 [Name("removeEventListener")] public extern void RemoveEventListener(HaxeString type, EventListener listener);
Пример #10
0
 public extern HTMLCollection GetElementsByClassName(HaxeString className);
Пример #11
0
 public extern NodeList QuerySelectorAll(HaxeString selectors);
Пример #12
0
 public extern Element QuerySelector(HaxeString selectors);
Пример #13
0
 public extern Event CreateEvent(HaxeString interface_);
Пример #14
0
 public extern HTMLCollection GetElementsByTagName(HaxeString localName);
Пример #15
0
 public extern Element CreateElement(HaxeString localName);
Пример #16
0
 [Name("addEventListener")] public extern void AddEventListener(HaxeString type, Delegate listener);
Пример #17
0
 [Name("addEventListener")] public extern void AddEventListener(HaxeString type, Delegate listener, HaxeBool capture, bool wantsUntrusted);
Пример #18
0
 public extern void SetAttribute(HaxeString name, HaxeString value);
Пример #19
0
 [Name("removeEventListener")] public extern void RemoveEventListener(HaxeString type, Delegate listener, HaxeBool capture);
Пример #20
0
 public extern Attr GetNamedItem(HaxeString name);
Пример #21
0
 public extern Window Open(HaxeString url, HaxeString target, HaxeString features);
Пример #22
0
 public extern void Add(HaxeString token);
Пример #23
0
 public extern TextDecoder(HaxeString label);
Пример #24
0
 public extern void Remove(HaxeString token);
Пример #25
0
 public extern TextMetrics MeasureText(HaxeString text);
Пример #26
0
 public extern Worker(HaxeString worker);
Пример #27
0
 public extern Node CreateTextNode(HaxeString text);
Пример #28
0
 [Name("addEventListener")] public extern void AddEventListener(HaxeString type, EventListener listener, HaxeBool capture);
Пример #29
0
 public extern MessageEvent(HaxeString type, dynamic eventInitDict);
Пример #30
0
 [Name("initEvent")] public extern void InitEvent(HaxeString type, HaxeBool bubbles, HaxeBool cancelable);