Exemplo n.º 1
0
        public void InvalidateTracks(bool force)
        {
            var trackArray = Tracks?.ToArray();

            if (trackArray == null || trackArray.Length == 0)
            {
                return;
            }

            var width = RenderWidth - Padding.Horizontal;

            if (width > 0)
            {
                if (trackArray == Renderer.Tracks && !force)
                {
                    return;
                }

                var settings = Renderer.Settings;
                settings.Width        = width;
                settings.Engine       = RenderEngine;
                settings.Scale        = Scale;
                settings.Layout.Mode  = LayoutMode;
                settings.StretchForce = StretchForce;
                settings.Staves.Id    = StavesMode;
                Renderer.UpdateSettings(settings);
                ModelUtils.ApplyPitchOffsets(settings, trackArray[0].Score);

                _initialRenderCompleted = false;
                _isRendering            = 1;

                Task.Factory.StartNew(() =>
                {
                    Renderer.Render(trackArray[0].Score, trackArray.Select(t => t.Index).ToArray());
                });
            }
            else
            {
                _initialRenderCompleted = false;
                _redrawPending          = true;
                _isRendering            = 0;
            }
        }
Exemplo n.º 2
0
        public void TestDisplayTranspositionPitchResultsInAccidental()
        {
            var import = new AlphaTexImporter();

            import.Init(ByteBuffer.FromBuffer(Encoding.UTF8.GetBytes("\\tuning none . e3.8")));
            var score = import.ReadScore();

            var settings = Settings.Defaults;

            // no transposition
            settings.TranspositionPitches = new [] { 0 };
            ModelUtils.ApplyPitchOffsets(settings, score);
            var helper     = new AccidentalHelper();
            var accidental = helper.ApplyAccidental(score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Notes[0]);
            var line       = helper.GetNoteLine(score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Notes[0]);

            Assert.AreEqual(AccidentalType.None, accidental);
            Assert.AreEqual(17, line);

            // one semitone up => one line up
            settings.TranspositionPitches = new[] { 1 };
            ModelUtils.ApplyPitchOffsets(settings, score);
            helper     = new AccidentalHelper();
            accidental = helper.ApplyAccidental(score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Notes[0]);
            line       = helper.GetNoteLine(score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Notes[0]);
            Assert.AreEqual(AccidentalType.None, accidental);
            Assert.AreEqual(16, line);

            // two semitones up => one line up + sharp
            settings.TranspositionPitches = new[] { 2 };
            ModelUtils.ApplyPitchOffsets(settings, score);
            helper     = new AccidentalHelper();
            accidental = helper.ApplyAccidental(score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Notes[0]);
            line       = helper.GetNoteLine(score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Notes[0]);
            Assert.AreEqual(AccidentalType.Sharp, accidental);
            Assert.AreEqual(16, line);
        }