Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thelowsunoverthemoon/mahler.c
Western music theory library in C99
https://github.com/thelowsunoverthemoon/mahler.c
api c c99 chords interval key-signatures library minimal music music-theory scale
Last synced: about 2 hours ago
JSON representation
Western music theory library in C99
- Host: GitHub
- URL: https://github.com/thelowsunoverthemoon/mahler.c
- Owner: thelowsunoverthemoon
- License: mit
- Created: 2020-08-19T02:08:50.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-01-29T19:22:19.000Z (8 months ago)
- Last Synced: 2024-09-24T21:19:35.841Z (about 7 hours ago)
- Topics: api, c, c99, chords, interval, key-signatures, library, minimal, music, music-theory, scale
- Language: C
- Homepage:
- Size: 195 KB
- Stars: 47
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
mahler.c
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/thelowsunoverthemoon/mahler.c/run_unit_tests.yml)
[![Static Badge](https://img.shields.io/badge/coverage-100%25-%23327da8)](https://github.com/thelowsunoverthemoon/mahler.c/tree/master/test)
[![Stack Overflow Badge](https://img.shields.io/badge/docs-purple)](https://github.com/thelowsunoverthemoon/mahler.c/blob/master/doc/README.md)
[![Static Badge](https://img.shields.io/badge/clang--format-brown)](https://github.com/thelowsunoverthemoon/mahler.c/tree/master/.clang-format)Simple library for Western music theory in C99
## Features
* Small & Easy-to-use
* Interval, Chord, Scale, and Key Signature functions
* No Internal Memory Allocation
* Supports Theoretical Keys (eg Fb+)
* No Accidental Limit (eg G 20th sharp)
* Enharmonically Correct (eg minor 6th of D is Bb, not A#)
* 100% Test Coverage## Example
Here's an example that creates the C4 Blues Scale, ascending:
```C
struct mah_note notes[7];
struct mah_scale scale = mah_get_scale(
(struct mah_note) {MAH_C, MAH_NATURAL, 4}, &MAH_BLUES_SCALE, notes, MAH_ASCEND, NULL
);
```And if you want to print it:
```C
char buf[MAH_DISP_LEN];
for (int i = 0; i < scale.size; i++) {
puts(mah_write_note(scale.notes[i], buf, MAH_DISP_LEN, NULL));
}
```See [here](ex) for more!
## Who's Mahler?
Gustav Mahler is one of my favourite composers; if you like the emotions of Wagner, and the ideas of Stravinsky, Mahler is the perfect middle ground! All his works have a flair of modernism that gives his emotional works a unique touch. You should definitely check him out, especially his Symphony No.5 in C# Minor, The Song of the Earth, and Symphony No.6 in A Minor.
## Documentation
See [here](doc/README.md)!
## Unit Tests
See [here](test)!
## Compiling
To compile, you can use ```cmake```. **Be sure to include the ```src``` and ```inc``` folders as folders to search for the source and header.** For example, given ```example.c``` and ```mahler``` is located in the same directory
```CMake
cmake_minimum_required(VERSION 3.10)
project(example)
set(MAHLER_PATH "${PROJECT_SOURCE_DIR}/mahler.c")add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c)
target_include_directories(
${PROJECT_NAME} PUBLIC
"${PROJECT_BINARY_DIR}"
"${MAHLER_PATH}/inc"
"${MAHLER_PATH}/src"
)add_subdirectory(${MAHLER_PATH})
target_link_libraries(${PROJECT_NAME} PUBLIC mahler)
```where ```MAHLER_PATH``` is the path to ```mahler```. It is also simple to compile via commandline.