thelowsunoverthemoon/mahler.c: Western music theory library in C

Simple library for western music theory in C99

  • Small and easy to use
  • Interval, Chord, Scale and Key Signature Functions
  • no internal memory allocation
  • Supports theoretical keys (like Fb+)
  • No sudden limit (e.g. G20th sharp)
  • Harmonically correct (e.g. the minor sixth of D is Bb, not A#)
  • 100% test coverage

Here’s an example that builds the C4 blues scale in ascending order:

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:

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));
}

Check here for more details!

Gustav Mahler is one of my favorite composers; If you like the sentiments of Wagner and the ideas of Stravinsky, Mahler is the perfect middle ground! All his works have a touch of modernity which gives a unique touch to his emotional works. 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.

Look here!

Look here!

To compile, you can use cmake. Be sure to include src And inc Folders as folders to find source and headers. For example, given example.c And mahler located in the same directory

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 route to mahler. Compiling via commandline is also simple.



<a href

Leave a Comment