AlphaTab.Model.JsonConverter available in C#? #425
-
QuestionIs using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AlphaTab.Model;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
// var score = ... // Omitted for brevity.
// This gives the error in VS: Error CS0234 The type or namespace name 'JsonConverter'
// does not exist in the namespace 'AlphaTab.Model' (are you missing an assembly reference?)
var json = AlphaTab.Model.JsonConverter.ScoreToJson(score);
}
}
} Your environment (if applicable)
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
The JsonConverter is a component specific to the web target. it is mainly used to transport various objects from the main browser thread to the web worker in the back. So far there was no need to bring the JsonConverter to the .net platform as it is mostly meant for the mentioned usecase. What would be the actual usecase for you to have JSON serialization? The most convenient way of "writing" new piece with alphaTab is definitely alphaTex. The JSON model might work, but is quite sensitive to mistakes. If your application provides writing new music pieces (by manipulating the data model directly) there is no built-in exporter so far. I once maintained an alphaTex exporter beside the importer but it was not used so I dropped it due to maintenance overhead. The "model editing APIs" and "file exporters" topics are rather deep down at the end of the backlog for alphaTab 1.5 To answer the question of this issue: The JsonConverter is and will likely not become available on .net. If you have some concrete needs (e.g. to save scores) feel free to open a feature request dedicated to that. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply. My use case is similar to the use case you described in that it involves being able to pass score objects between different components:
Let me ask about AlphaTex though. Is it capable of representing all the same information as a Guitar Pro file? For instance, if you took a .gp file, got the Score model from it with AlphaTab, then--assuming there was an AlphaTex exporter--could you export AlphaTex without losing any information? |
Beta Was this translation helpful? Give feedback.
-
I would say mostly yes. There might be some missing small bits here and there but most features alphaTab supports, also alphaTex provides as input syntax. Any missing piece should be added quickly in case somebody would need it 😉 For alphaTab 1.1 I plan to not add any big features anymore, but the scope of 1.2 is not really fixed. I could also refocus and create an exporter in 1.2 (or an 1.1.1). In the end it depends on what brings the most value to the integrators.
So I guess a GuitarPro7 export would bring the biggest value in short term. |
Beta Was this translation helpful? Give feedback.
-
FYI: I added #443 as work item for 7.2 which should allow both usecases: storing dynamically generated songs and transmitting files over the wire. I will check if the JSON serializer would be sort-of compatible with C# as part of this issue. Unfortunately this will likely pull a new dependency |
Beta Was this translation helpful? Give feedback.
-
Just transferred this question to the new GitHub Discussions and I would like to close it with the following answer: In version 1.1 there is no good way to save files or exchange it between different platforms. I entered following items for 1.2:
|
Beta Was this translation helpful? Give feedback.
Just transferred this question to the new GitHub Discussions and I would like to close it with the following answer:
In version 1.1 there is no good way to save files or exchange it between different platforms. I entered following items for 1.2: