Export Data Model
After alphaTab has loaded a full Score
object from any input source, it can also be exported again to one of the supported export formats.
Supported export formats:
- Guitar Pro 7 (alphaTab.exporter.Gp7Exporter) since 1.2.0-alpha.75
note
More exporters are planned for the 1.5 release unless special feature requests of users are incoming.
To export a Score
object the corresponding exporter needs to be created and called. Then the resulting binary array can be used further to
trigger a download, send it to a server, save it to a file etc.
- JavaScript
- C#
const exporter = new alphaTab.exporter.Gp7Exporter();
const data = exporter.export(api.score, api.settings); // will return a Uint8Array
// trigger download
const a = document.createElement('a');
a.download = api.score.title.length > 0 ? api.score.title + '.gp' : 'Untitled.gp';
a.href = URL.createObjectURL(new Blob([data]));
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
var exporter = new AlphaTab.Exporter.Gp7Exporter();
AlphaTab.Core.EcmaScript.Uint8Array data = exporter.export(api.Score, api.Settings);
ArraySegment<byte> bytes = data.Data;
string fileName = api.Score.Title.Length > 0 ? api.Score.Title + ".gp" : "Untitled.gp";
using(var fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create))
{
fs.Write(bytes.Array, bytes.Offset, bytes.Count);
}