Installation (.NET)
alphaTab on .NET runs in console applications, servers, and Windows desktop UIs. It ships as two NuGet packages depending on where you need it.
Installโ
Two packages cover every .NET scenario:
AlphaTabtargets .NET Standard 2.0. Use it for console tools, servers, and headless rendering.AlphaTab.Windowstargets .NET 8.0 and adds WPF and WinForms UI controls. It brings in the base package as a dependency.
Install through the .NET CLI:
dotnet add package AlphaTab
# or, for WPF / WinForms:
dotnet add package AlphaTab.Windows
Or add the reference directly to your .csproj:
<ItemGroup>
<PackageReference Include="AlphaTab" Version="1.6.1" />
</ItemGroup>
Render from a console appโ
Console applications skip the UI controls and drive alphaTab through its low-level classes โ ScoreLoader for parsing files, ScoreRenderer for producing images. This example loads a score, renders it to Skia images, and reports the total canvas size:
using AlphaTab;
using AlphaTab.Importer;
using AlphaTab.Rendering;
using SkiaSharp;
var score = ScoreLoader.LoadScoreFromBytes(File.ReadAllBytes(args[0]));
var settings = new Settings();
settings.Core.Engine = "skia";
var renderer = new ScoreRenderer(settings)
{
Width = 970
};
var partialImages = new List<SKImage>();
var totalWidth = 0;
var totalHeight = 0;
renderer.PartialRenderFinished.On(r =>
{
partialImages.Add((SKImage)r.RenderResult);
});
renderer.RenderFinished.On(r =>
{
totalWidth = (int)r.TotalWidth;
totalHeight = (int)r.TotalHeight;
});
renderer.RenderScore(score, new double[] { 0 });
More console samples live at github.com/CoderLine/alphaTabSamplesDotNet.
Render in WPFโ
The AlphaTab.Windows package ships a WPF control with the main functionality out of the box. Drop it into any XAML:
<Window x:Class="AlphaTab.Samples.Wpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wpf="clr-namespace:AlphaTab.Wpf;assembly=AlphaTab.Windows"
Title="alphaTab" Height="800" Width="600" WindowState="Maximized">
<wpf:AlphaTab Tracks="{Binding TracksToDisplay}" />
</Window>
Expose the tracks to render from your view model:
public IEnumerable<AlphaTab.Model.Track> TracksToDisplay { get; }
Render in WinFormsโ
The WinForms control is the counterpart for classic Windows Forms UIs. Instantiate it in code and add it to a form:
using AlphaTab.WinForms;
var control = new AlphaTabControl
{
Dock = System.Windows.Forms.DockStyle.Fill
};
Controls.Add(control);
control.Tracks = new[] { score.Tracks[0] };
The WinForms control has a slightly reduced feature set compared to WPF. It cannot render semi-transparent cursors during playback because WinForms lacks proper transparency support. Display and audio playback themselves work identically.
Dependenciesโ
alphaTab on .NET carries a small number of third-party dependencies:
- Rendering. Either the built-in GDI+ graphics or alphaSkia, which wraps the Skia engine used by Chrome. alphaSkia is the recommended engine and is significantly faster and more consistent across platforms than GDI+.
- Audio. NAudio drives audio playback of the synthesised MIDI output.
Reach out on GitHub if you need alphaTab wired to a different UI framework or audio backend.