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