
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
= Jazz Model
Jazz Model is full ActiveRecord model of concepts in Jazz theory, establishing relationships between chords and scales, and much more. Aside from representing jazz theory relationships in the database, jazz model can do key conversions and other operations on these jazz "objects". By default it uses an in-memory sqlite3 database, but it could be persisted elsewhere.
== Architecture Overview
The core of Jazz Toolbox is a full Ruby object model representing concepts of Jazz theory, distilled to their most basic concepts and architected in a very abstract manner. The system is data-centric and all "rules" (for example, the tones in a C7 chord) in theory are self-contained in the database.
All chord/scale/mode/etc. definitions are stored as a mathematical system (sequences of numbers) which are then used to perform calculations. For example, putting some chord in a different key is a matter of adding a semitone delta and doing modulo 12.
While there are currently many chord calculators in existence, to my knowledge this project is the first one that attempts to fully represent the entirety of Jazz theory as a mathematical/computational system exposed through an elegant object model.
Note: the current database consists entirely of my own personal knowledge of Jazz theory. I haven't yet scoured through the Jazz theory literature to formalize and expand the current database of chords, scales, and chord-scales. There's still a lot of work to do and I have lots of ideas for how to expand this.
== Core Features
== Installation
Simply include the gem in your Gemfile:
gem "jazz_model"
From here you can begin using the classes under +JazzModel+ directly, but it won't be much use until you load the definitions:
JazzModel::Base.load_definitions
== Examples using Default Definitions
Everything is under the JazzModel namespace, so first do this if you want to use these classes directly:
include JazzModel
Getting a Chord object:
Chord['maj7'] Chord['Bbmaj7'] # <- With Key Context Chord['Abmaj7#11'] ...
Getting a Scale object:
Scale['Major'] Scale['Melodic Minor'] Scale['Diminished'] ...
Getting a particular mode of a scale:
Scale['Major'].modes['Dorian'] # By Mode Name Scale['Major'].modes[2] # By Mode Index
Scale['Major']['Dorian'] Scale['Major'][2]
Enumerate notes of a Chord:
Chord['maj'].notes # Defaults to C without specified key context
Chord['Ebmaj7'].notes
Chord['maj7'].in_key_of('Eb').notes
Chord['Bmaj7#11'].notes
Chord['Falt'].notes Chord['F7b9#9'].notes
Chord['Gbmaj7'].notes
Chord['F#maj7'].notes
Enumerate notes of a Scale:
Scale['Major'].notes # Defaults to C without specified key context
Scale['Eb Major'].notes
Scale['Major'].in_key_of('Eb').notes
Scale['Whole Tone'].notes
Scale['Bebop'].notes
Enumerate notes from a Scale Mode:
Scale['Major'].in_key_of('Eb').modes['Dorian'].notes
Scale['Melodic Minor']['Lydian Dominant'].notes
Enumerate scale modes associated with a chord:
Chord['min7'].modes.names # .names == .map(&:name)
Chord['min7'].modes[0].scale.name
Chord['Amin7'].modes.names
Enumerate chords associated with a scale mode:
Scale['Major']['Dorian'].chords.symbols
Scale['Major'][4].chords.symbols
Ruby Example Problem: Find all chords associated with the Major (Ionian) scale and print each on a new line with the chord tones.
Scale['Major'].chords.map {|c| c.name + ': ' + c.notes.join(', ')} * "\n"
Major 6: C, E, G, A
Dominant 6/9: C, E, G, Bb, D, A
These examples should show that with the power of Ruby and the elegant nature of this API, extracting Jazz data from the system is a breeze (even fun!).
== Definitions Available
The default definition is just named "default" and is loaded when you run JazzModel::Base.load_definitions without argument, though you can give a custom argument to this to load a different definition:
JazzModel::Base.load_definitions(:my_custom_set)
Currently there are two definitions available:
== Creating Definitions
The gem has a distinction between classes such as +Chord+ and the actual definitions such as "C Major Chord". Definitions are simply packaged set of instructions for initializing the objects with data (which get put in the database). Since by default jazz model uses an in-memory sqlite3 database, definitions need to be loaded when your application loads.
To create a definition, simply do this:
JazzModel::Definition.define :my_definition => [:keys] do
end
Within the block you'll want to create whatever data is necessary to comprise your definitions. For examples of definitions, see lib/jazz_model/definitions in the project. The argument to define acts like rake tasks - use the hash value to define which dependencies your definition has. In the above case defining "my_definition" will first ensure the "keys" definition is already defined.
== Anticipated Future Features
FAQs
Unknown package
We found that jazz_model demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.