PanoramicData.MusicGeneration 0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package PanoramicData.MusicGeneration --version 0.1.1
                    
NuGet\Install-Package PanoramicData.MusicGeneration -Version 0.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PanoramicData.MusicGeneration" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PanoramicData.MusicGeneration" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="PanoramicData.MusicGeneration" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PanoramicData.MusicGeneration --version 0.1.1
                    
#r "nuget: PanoramicData.MusicGeneration, 0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PanoramicData.MusicGeneration@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PanoramicData.MusicGeneration&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=PanoramicData.MusicGeneration&version=0.1.1
                    
Install as a Cake Tool

PanoramicData.MusicGeneration

NuGet License: MIT .NET 10 CI

Deterministic, seeded music generation for .NET. A seed becomes a whole song: a key and scale, a tempo, a new chord every bar, a bass line, a tune that never loops, and a drum pattern, rendered to PCM. It also hands back the list of notes it played, so you can score a pitch tracker, an onset detector or a fingerprinting library against the truth.

  • Reproducible for ever. The same seed, length, sample rate and style give the same song on any machine and any .NET version: the library carries its own random number generator (PCG32) and its own bit-exact sine.
  • Varied. Tempo, key, scale, harmony, melody, drum pattern, timbre, tuning and lead-in all come from the seed. Nothing repeats exactly inside a song, so any few seconds say where in the song they are.
  • Ground truth included. Every note and drum hit comes back with its start, length, MIDI note and rendered frequency.
  • No samples, no copyright. Everything is synthesised from sine waves and noise by arithmetic you can read in an afternoon.
  • Educational. The demo site explains the maths: equal temperament, harmonics, envelopes, noise and the random number generator.

Try it in your browser: the demo runs the whole library locally (once published, at the address shown in the repository's About box). See docs/DEMO.md.

Installation

dotnet add package PanoramicData.MusicGeneration

Targets .NET 10. Not yet published to NuGet.

Quick start

using PanoramicData.MusicGeneration;

// 30 seconds of music at 22,050 Hz from seed 42.
GeneratedSong song = SongGenerator.Generate(seed: 42, seconds: 30, sampleRate: 22050);

float[] samples = song.Samples;               // mono, loudest sample exactly 0.9
byte[] wav = song.ToWav();                    // 16-bit mono WAV, ready to save or play

Console.WriteLine($"{song.Info.TempoBpm} bpm, {Pitch.NameOf(song.Info.RootMidi)} {song.Info.ScaleName}");
foreach (var note in song.Notes.Where(n => n.Voice == VoiceKind.Melody).Take(5))
{
	Console.WriteLine($"{note.StartSeconds:0.00}s  {Pitch.NameOf(note.MidiNote)}  {note.FrequencyHz:0.0} Hz  for {note.DurationSeconds:0.00}s");
}

Choose what may vary, or switch parts off, with a SongStyle:

var style = new SongStyle
{
	MinTempoBpm = 100, MaxTempoBpm = 120,
	Scales = [Scales.MinorPentatonic, Scales.Dorian],
	MelodyLowMidi = 60, MelodyHighMidi = 84,   // middle C to C6
	Drums = false                              // no drums
};
var song = SongGenerator.Generate(7, 20, 44100, style);

What a song contains

Part How it is made
Pad One triad per bar on a random scale degree with a random inversion; 3 harmonics, slow decay.
Bass A note on most beats: the chord root, sometimes its fifth; low, 3 harmonics, quick decay.
Melody A random walk through the scale, clamped to the melody range, with half, one or one-and-a-half beat notes, 15% rests, 6 harmonics and a gentle vibrato.
Kick A sine whose frequency falls as <code>f<sub>0</sub> + 110 e<sup>-28t</sup></code>.
Snare, hi-hat White noise through a first-difference filter times a fast decay.

Full description, formulas and parameters: docs/DESIGN.md.

Determinism

Reproducibility is the point, so it is tested hard: a golden hash of a generated song, golden values for the random number generator (they match the published PCG32 reference outputs), and a check that changing the sample rate does not change the notes. SongGenerator.Version names the algorithm version; any change that alters the output for an existing seed is a breaking change and increments it.

If arithmetic speed matters more than bit-exactness (for example in an interpreted WebAssembly runtime, where the library's own sine is slow), set SongStyle.UsePlatformSine. The notes and choices are unchanged; only the last bit of each sample may then differ between operating systems.

Documentation

Document For
docs/DESIGN.md Goals, algorithm, parameters, determinism contract, API
docs/DEMO.md The browser demo and how to host it
docs/DEVELOPMENT_PROMPT.md The brief for developing the library further

Development

dotnet build                                          # warnings are errors
dotnet test --project PanoramicData.MusicGeneration.Test
dotnet run --project PanoramicData.MusicGeneration.Demo

The library has 100% line and branch coverage from the unit tests. Contributions: see CONTRIBUTING.md and SECURITY.md.

License

MIT, see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PanoramicData.MusicGeneration:

Package Downloads
PanoramicData.MusicGeneration.SoundFonts

Optional SoundFont instrument-bank rendering for PanoramicData.MusicGeneration using MeltySynth. Caller-supplied SF2 assets, inspectable replay metadata and independent stems.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.33 248 10/22/2026
0.1.21 114 10/22/2026
0.1.20 121 10/21/2026
0.1.19 136 10/21/2026
0.1.16 115 10/20/2026
0.1.15 118 10/20/2026
0.1.14 100 10/20/2026
0.1.13 99 10/20/2026
0.1.11 92 10/19/2026
0.1.6 108 10/19/2026
0.1.1 135 10/19/2026