public void JsonDeserializationTestWithProxyOnRealExample()
        {
            var assembly          = typeof(SerializationTests).Assembly;
            var scoreResourceName = $"{typeof(SerializationTests).Namespace}.Assets.JohannChristophBachFull3.0.xml";

            using (var scoreStream = assembly.GetManifestResourceStream(scoreResourceName))
                using (var scoreReader = new StreamReader(scoreStream))
                {
                    var sw = new Stopwatch();
                    sw.Start();

                    var scoreString = scoreReader.ReadToEnd();
                    var settings    = new HtmlScoreRendererSettings();
                    settings.RenderSurface = HtmlScoreRendererSettings.HtmlRenderSurface.Svg;
                    var profile = SMuFLMusicFont.CreateFromJsonResource <SerializationTests>("bravura_metadata.json");
                    settings.SetMusicFont(profile, "Bravura", "/fakeuri");
                    settings.Scale = 1;
                    settings.CustomElementPositionRatio = 0.8;
                    settings.IgnorePageMargins          = true;
                    var renderer = new HtmlSvgScoreRenderer(new XElement("root"), "testCanvas", settings);

                    renderer.Render(scoreString.ToScore());

                    sw.Stop();

                    var metadataAsProxy = (LazyLoadJsonProxy)profile.SMuFLMetadata;
                    Debug.WriteLine($"All rendering done in {sw.Elapsed}");
                    var deserTime = metadataAsProxy.GetTotalDeserializationTimeWithChildElements();
                    Debug.WriteLine($"Deserialization done in {deserTime}");
                }
        }
        public void TestBinarySerialization()
        {
            var profile = SMuFLMusicFont.CreateFromJsonResource <SerializationTests>("Assets.bravura_metadata.json", false);

            using (var ms = new MemoryStream())
            {
                var serializationSw = new Stopwatch();
                serializationSw.Start();
                profile.SerializeMetadataAsBinary(ms);
                serializationSw.Stop();
                var serializedData = ms.ToArray();

                var deserializationSw = new Stopwatch();
                deserializationSw.Start();
                var newProfile = SMuFLMusicFont.CreateFromBinaryArray(serializedData);
                deserializationSw.Stop();

                Debug.WriteLine($"Serialization: {serializationSw.Elapsed}, Deserialization: {deserializationSw.Elapsed}");
            }
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();
            var family = dummyTextBlock.FontFamily;

            //noteViewerTest.IsMusicPaperMode = true;
            var useSMuFL = true;

            if (useSMuFL)
            {
                var fontProfile =
                    SMuFLMusicFont.CreateFromJsonResource <MainWindow>("Assets.bravura_metadata.json");
                //SMuFLMusicFont.CreateFromBinaryResource<MainWindow>("Assets.bravura_metadata.bin");
                noteViewerTest.SetFont(family, fontProfile);
                noteViewer1.SetFont(family, fontProfile);
                noteViewer2.SetFont(family, fontProfile);
                noteViewer3.SetFont(family, fontProfile);
            }

            LoadTestModel(HookDirectionAlgorithm.ProductionCandidate);
        }