Mtf.Music
1.0.2
dotnet add package Mtf.Music --version 1.0.2
NuGet\Install-Package Mtf.Music -Version 1.0.2
<PackageReference Include="Mtf.Music" Version="1.0.2" />
<PackageVersion Include="Mtf.Music" Version="1.0.2" />
<PackageReference Include="Mtf.Music" />
paket add Mtf.Music --version 1.0.2
#r "nuget: Mtf.Music, 1.0.2"
#:package Mtf.Music@1.0.2
#addin nuget:?package=Mtf.Music&version=1.0.2
#tool nuget:?package=Mtf.Music&version=1.0.2
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
Melodyinherits fromList<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 | Versions 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. |
-
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.