Mtf.Music 1.0.2

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

Mtf.Music

A lightweight C# library for representing musical notes, melodies, and timing based on physical sound properties (frequency, wavelength, and musical theory abstractions).

The library focuses on data-driven musical representation, not UI or audio playback.


Core Concept

Instead of treating notes as symbolic values only, this library models them using:

  • Fundamental frequency (A4 = 440 Hz default)
  • Semitone deviation
  • Derived frequency using equal temperament tuning
  • Physical wavelength based on speed of sound

Features

🎵 Musical representation

  • Strongly typed notes (C4, D#5, etc.)
  • Support for natural and sharp/flat notes
  • Enum-based note duration (NoteType)

🎼 Melody construction

  • Melodies are defined as ordered sequences of notes
  • Built-in predefined melodies

⏱ Timing system

  • Time signature support
  • BPM-based timing calculation
  • Accurate note duration computation in milliseconds

🔊 Physical audio model

  • Frequency calculation using:
    • f = f0 * 2^(n/12)
  • Wavelength calculation:
    • λ = speedOfSound / frequency

Project Structure


Mtf.Music
│
├── Note                  # Base musical note model
├── Melody                # Sequence of notes with timing
├── TimeSignature        # Beat/bar structure
├── NoteType             # Duration (whole, half, quarter, etc.)
├── MusicalScale         # Note name mapping
│
├── Notes/               # Generated strongly typed notes
│   ├── C4, D4, E4...
│   ├── Cs4_Db4 (sharp/flat aliases)
│
├── Melodies/            # Predefined songs
│   ├── BociBoci
│   ├── JingleBells
│   ├── ImperialMarch
│   ├── NeverGonnaGiveYouUp


Example Usage

Creating a melody

using Mtf.Music;
using Mtf.Music.Notes;
using Mtf.Music.Melodies;

var melody = new BociBoci();

Console.WriteLine(melody);

Working with notes

var note = new C4(NoteType.Eighth);

Console.WriteLine(note.Name);
Console.WriteLine(note.Frequency);
Console.WriteLine((ushort)note); // rounded frequency

Timing calculation

var melody = new BociBoci();

ushort ms = melody.GetNoteLength(NoteType.Quarter);

Design Notes

  • Melody inherits from List<Note> for direct sequence manipulation
  • Notes are immutable in identity but configurable via FundamentalFrequency
  • Default tuning is A4 = 440 Hz, adjustable globally per melody
  • Sharp/flat notes are represented as alias classes (e.g. Cs4_Db4)

Limitations

  • No built-in audio rendering
  • No MIDI export
  • No real-time synthesis
  • No dynamic rhythm quantization

This is a representation layer only, intended for further processing or audio backend integration.

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 Mtf.Music:

Package Downloads
Mtf.Lego.Mindstorms.EV3

Library for interacting with Lego Mindstorms EV3 robots.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 143 6/4/2026
1.0.1 132 5/28/2026