Mics.CodeAnalysis 1.0.0

dotnet add package Mics.CodeAnalysis --version 1.0.0
                    
NuGet\Install-Package Mics.CodeAnalysis -Version 1.0.0
                    
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="Mics.CodeAnalysis" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mics.CodeAnalysis" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Mics.CodeAnalysis" />
                    
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 Mics.CodeAnalysis --version 1.0.0
                    
#r "nuget: Mics.CodeAnalysis, 1.0.0"
                    
#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 Mics.CodeAnalysis@1.0.0
                    
#: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=Mics.CodeAnalysis&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Mics.CodeAnalysis&version=1.0.0
                    
Install as a Cake Tool

Mics

Music In C Sharp. Turn C# source code into music, or use the fluent API to compose sound from your own code.

Install

CLI tool:

dotnet tool install -g Mics.Cli

Library:

dotnet add package Mics.Core

CLI

mics compose <input.cs> -o <output.wav> [options]
mics scales
mics instruments

Options:

  • -o, --output <file> — output WAV file (required)
  • --scale <name> — major, minor, dorian, mixolydian, pentatonic, blues
  • --tempo <bpm> — beats per minute (default: 120)
  • --instrument <name> — sine, triangle, square, sawtooth
  • -v, --version — show version and exit

Examples:

mics compose samples/Hello.cs -o hello.wav
mics compose samples/Hello.cs -o hello-minor.wav --scale minor --tempo 90

Library

The Sound class is the entry point. Every method returns a Track you can chain.

using Mics;

Sound.Note("C4").Save("note.wav");
Sound.Melody("C4", "E4", "G4").Save("melody.wav");
Sound.Chord("C4", "E4", "G4").Save("chord.wav");

Chaining with tempo and instrument:

Sound.Note("C4", beats: 0.5)
    .Note("E4", beats: 0.5)
    .Rest(1)
    .Note("G4")
    .Bpm(100)
    .Instrument("triangle")
    .Save("phrase.wav");

Multi-voice song:

Sound.Song()
    .Tempo(100)
    .Voice("lead", "triangle", v => v
        .Note("C4").Note("E4").Note("G4").Note("C5"))
    .Voice("bass", "sawtooth", v => v
        .Note("C2", beats: 4))
    .Save("song.wav");

In-memory output:

byte[] wav = Sound.Note("A4").ToWavBytes();
double[] pcm = Sound.Note("A4").ToSamples();

Note names

Scientific pitch notation. Enharmonic equivalents normalize.

  • C4, A#3, Bb5, Db2
  • Case-insensitive: c4 equals C4
  • Bb3 equals A#3

MIDI numbers 0-127 are the canonical internal representation, so NoteName.FromMidi(60) returns middle C.

Instruments

Four built-in waveforms, each with its own ADSR envelope:

  • sine — pure tone, gentle attack
  • triangle — softer harmonics, flute-like
  • square — hollow, retro
  • sawtooth — bright, buzzy

Scales

  • major — bright, resolved
  • minor — melancholic
  • dorian — jazzy
  • mixolydian — bluesy rock
  • pentatonic — safe, pleasant
  • blues — gritty

How it works

CLI mode parses C# with Roslyn, walks the syntax tree, and maps each node to a musical event. Each type declaration (class, struct, record, interface, enum) becomes a voice with its own timeline; voices play in parallel.

Library mode skips the parser entirely. You write the notes. The library handles timing, instruments, mixing, and WAV synthesis.

License

MIT

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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 93 10/4/2026