{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "# Modes\n", "\n", "Here we demonstrate some of the capabilities of the {class}`~pyabc2.Key` class." ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "from pyabc2 import Key" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": {}, "outputs": [], "source": [ "mode_abbrs = [\"ion\", \"dor\", \"phr\", \"lyd\", \"mix\", \"aeo\", \"loc\"]\n", "\n", "modes = [Key(f\"G{m}\") for m in mode_abbrs]\n", "modes" ] }, { "cell_type": "markdown", "id": "3", "metadata": {}, "source": [ "## Relatives" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "[\n", " modes[0].relative(abbr)\n", " for abbr in mode_abbrs\n", "]" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": {}, "outputs": [], "source": [ "modes[0].relative_minor" ] }, { "cell_type": "code", "execution_count": null, "id": "6", "metadata": {}, "outputs": [], "source": [ "modes[-1].relative_major" ] }, { "cell_type": "markdown", "id": "7", "metadata": {}, "source": [ "## Scale\n", "\n", "Various representations of notes in the scale." ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "for m in modes:\n", " m.print_scale()" ] }, { "cell_type": "code", "execution_count": null, "id": "9", "metadata": {}, "outputs": [], "source": [ "for m in modes:\n", " m.print_scale_degrees_wrt_major()" ] }, { "cell_type": "code", "execution_count": null, "id": "10", "metadata": {}, "outputs": [], "source": [ "for m in modes:\n", " m.print_intervals()" ] }, { "cell_type": "code", "execution_count": null, "id": "11", "metadata": {}, "outputs": [], "source": [ "for m in modes:\n", " m.print_intervals(fmt=\"-\")" ] }, { "cell_type": "code", "execution_count": null, "id": "12", "metadata": {}, "outputs": [], "source": [ "for m in modes:\n", " m.print_scale_chromatic_values()" ] }, { "cell_type": "code", "execution_count": null, "id": "13", "metadata": {}, "outputs": [], "source": [ "from fractions import Fraction\n", "\n", "from pyabc2 import Tune\n", "\n", "abc = \"\"\"\\\n", "T: G modes\n", "K: G\n", "\"\"\"\n", "for m in modes:\n", " abc += f\"P: {m.mode}\\n\"\n", " abc += \" \".join(\n", " pc.to_pitch(octave=4 if pc.nat in \"GAB\" else 5)\n", " .to_note(duration=Fraction(\"1/4\"))\n", " .to_abc(key=Key(\"G\"))\n", " for pc in m.scale\n", " ) + \" |\\n\"\n", "abc += \"|]\"\n", "\n", "print(abc)\n", "\n", "Tune(abc)" ] }, { "cell_type": "markdown", "id": "14", "metadata": {}, "source": [ "## Chromatic" ] }, { "cell_type": "code", "execution_count": null, "id": "15", "metadata": {}, "outputs": [], "source": [ "for m in modes:\n", " m.print_chromatic_scale_degrees()" ] }, { "cell_type": "code", "execution_count": null, "id": "16", "metadata": {}, "outputs": [], "source": [ "for m in modes:\n", " m.print_chromatic_scale_degrees(acc_fmt=\"#/b\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 5 }