{"id":18547614,"url":"https://github.com/singond/music","last_synced_at":"2025-05-15T07:34:26.308Z","repository":{"id":57734863,"uuid":"134102664","full_name":"Singond/Music","owner":"Singond","description":"Java implementation of the Western music theory.","archived":false,"fork":false,"pushed_at":"2022-06-07T17:15:37.000Z","size":272,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-17T09:43:19.012Z","etag":null,"topics":["java-library","music"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Singond.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-19T22:33:41.000Z","updated_at":"2022-06-06T20:04:46.000Z","dependencies_parsed_at":"2022-08-24T11:20:33.312Z","dependency_job_id":null,"html_url":"https://github.com/Singond/Music","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Singond%2FMusic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Singond%2FMusic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Singond%2FMusic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Singond%2FMusic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Singond","download_url":"https://codeload.github.com/Singond/Music/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254297578,"owners_count":22047525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java-library","music"],"created_at":"2024-11-06T20:30:11.343Z","updated_at":"2025-05-15T07:34:26.265Z","avatar_url":"https://github.com/Singond.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"_Note: The repository has been filtered to avoid possible copyright violation.\nAs a consequence, your local version may not agree with upstream. Sorry for\nany inconvenience._\n\nMusic Theory for Java\n=====================\nJava implementation of Western music theory.\n\nThis library implements the widely used concepts in the Western music theory\nlike pitches, pitch classes, intervals, keys, scales, chords etc. in a type-safe\nmanner, using immutable value objects wherever possible.\n\nAdding as Dependency\n====================\nThe library is now hosted at Maven Central\n\u003chttps://mvnrepository.com/artifact/io.github.singond/music/\u003e.\nPreviously, it was hosted on JCenter, before the service was shut down.\nThe existing releases are apparently still available,\nbut new versions will only be published to Maven Central.\n\nMaven\n-----\nIn `pom.xml`:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.github.singond\u003c/groupId\u003e\n  \u003cartifactId\u003emusic\u003c/artifactId\u003e\n  \u003cversion\u003e0.8.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nGradle\n------\nIn `build.gradle`:\n\n```groovy\nrepositories {\n\tmavenCentral()\n}\ndependencies {\n\timplementation 'io.github.singond:music:0.8.0'\n}\n```\n\nUsage\n=====\n\nBasics\n------\nThe core types implementing music concepts are the following:\n\n- `Pitch`: The pitch of a musical note, consisting of a _pitch class_ and an\n  octave number, like “C4” (C in the fourth octave) or “F#5” (F sharp in\n  the fifth octave).\n- `PitchClass`: The group of all pitches an octave apart, like “C” or “Ab”\n  (A flat). This is like `Pitch` with octave information erased.\n- `Interval`: An interval between two pitches, like “minor third”.\n- `Key`: A musical key, like “E major” or “F sharp minor”.\n- `KeyType`: A type of a musical key, like “major” or “minor”.\n- `Chord`: A group of _pitch classes_, like “major triad at A” (A, C#, E).\n- `ChordVoicing`: A group of _pitches_, like “major triad at A4” (A4, C#5, E5).\n- `ChordType`: A type of a chord, like “major triad” or “diminished seventh”.\n\nThere are also some utility classes for manipulating the objects:\n\n- `Pitches`: for manipulating instances of `Pitch` and `PitchClass`,\n- `Intervals`: for manipulating instances of `Interval`,\n- `Keys`: for working with instances of `Key`.\n\nExamples\n--------\nFor brevity, the following examples don't show the `System.out.println(var)`.\n\nCreate pitch from pitch class and octave:\n\n```\nPitch p = Pitch.of(PitchClass.D, 4);\n\u003e\u003e D4\n```\n\nEquality and enharmonicity:\n\n```\nPitch dSharp = Pitch.DS4;\nPitch eFlat = Pitch.EB4;\nboolean equal = dSharp.equals(eFlat);\n\u003e\u003e false\nboolean enharm = dSharp.isEnharmonicWith(eFlat);\n\u003e\u003e true\n```\n\nGet the major third above A4:\n\n```\nPitch p = Pitch.A4.transposeUp(SimpleInterval.MAJOR_THIRD);\n\u003e\u003e C#5\n```\nGet the pitch classes in the key of A major and get the second raised degree:\n\n```\nKey key = Keys.A_MAJOR;\n\u003e\u003e A major\n\nList\u003cPitchClass\u003e scale = key.degrees();\n\u003e\u003e [A, B, C#, D, E, F#, G#]\n\nPitchClass tonic = key.tonic();\n\u003e\u003e A\n\nPitchClass secondRaised = key.degree(Degree.II_RAISED);\n\u003e\u003e B#\n```\n\nGenerate the E major scale between A3 and D5:\n\n```\nSet\u003cPitchClass\u003e pcs = Keys.E_MAJOR.pitchClasses();\nList\u003cPitch\u003e range = Pitches.allBetween(Pitch.A3, Pitch.D5, pcs);\n\u003e\u003e [A3, B3, C#4, D#4, E4, F#4, G#4, A4, B4, C#5]\n```\n\nGet the major triad with Eb as root:\n\n```\nChord c = Chords.chordAtRoot(PitchClass.E_FLAT, Chords.MAJOR_TRIAD);\n\u003e\u003e [Eb, G, Bb]\n```\n\nGet the first inversion of a major triad with Eb as root:\n\n```\n// Root position:\nPitchClass root = PitchClass.E_FLAT;\nChordType type = Chords.MAJOR_TRIAD;\nChord chord = Chords.chordAtRoot(root, type);\n\u003e\u003e [Eb, G, Bb]\n\n// First inversion:\nchord = chord.invert(1);\n\u003e\u003e [G, Bb, Eb]\n\n// Alternatively, invert the chord type:\ntype = type.invert(1);\nchord = Chords.chordAtRoot(root, type);\n\u003e\u003e [G, Bb, Eb]\n```\n\nGet the second inversion of a major triad which has Bb in bass:\n\n```\nPitchClass bass = PitchClass.B_FLAT;\nChordType type = Chords.MAJOR_TRIAD.invert(2);\nChord chord = Chords.chordAtBass(bass, type);\n\u003e\u003e [Bb, Eb, G]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingond%2Fmusic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsingond%2Fmusic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingond%2Fmusic/lists"}