Giter Club home page Giter Club logo

analyticpiano's Introduction

Overview

ANALYTIC PIANO (formerly HarmonyLab) is an open-source application for the study of music theory and keyboard skills that takes input from a MIDI keyboard and outputs staff notation. Various analytical vocabularies of melody and harmony are represented. As a practice aid and exercise platform that operates across aural, visual, and tactile domains, this tool accelerates the acquisition of fluency in certain fundamentals of tonal music.

Supported Web Browsers

As of December 2023, Google Chrome, Microsoft Edge, Opera, and Chromium all include the WebMIDI support on which this app depends. There is cross-platform support for WebMIDI on desktop and laptop computers (Apple desktop OS, Windows, Linux) but iPads unfortunately lack this support.

Heroku Deployment

This application can be deployed to any platform that supports python and django. Heroku is one such platform, a cloud platform as a service provider (PaaS) that provides for easy deployments from GitHub.

Create a Heroku app. Deploy from the desired branch of this Github repository; the Python buildpack and the Heroku Postgres add-on will be supplied on the basis of ./Procfile, ./Pipfile, and ./runtime.txt.

Add the following Config Variables on the Settings page:

SECRET_KEY = your-password
DJANGO_SETTINGS_MODULE = harmony.settings.heroku
ALLOWED_HOSTS = ["your-app-name.herokuapp.com"]

Note that automatic deployments are good for testing but these should be disabled when the site is in active use.

To manage the app via the Heroku CLI and to and create an admin account for the database, use these terminal commands:

$ heroku login # one-time setup
$ heroku apps # view app names for your login
$ heroku run python manage.py migrate --app HEROKU_APP_NAME
$ heroku run python manage.py createsuperuser --app HEROKU_APP_NAME

Running Locally on Linux or WSL2

• Get Python 3.10.13 and Pip. Typical setup commands:

wget https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tgz
tar -xzf Python-3.10.13.tgz 
cd Python-3.10.13
./configure --enable-optimizations # ~1 minute
make -j 2 # ~5 minutes
sudo make install # ~1 minutes
# optional: run `python3.10` to check installation (should show "Python 3.10.13") then `exit()`
cd ../
sudo rm -rf ./Python-3.10.13
sudo rm -rf ./Python-3.10.13.tgz 
# optional: run `ls ./Python-3.10.13*` to check removal of installation files
sudo apt-get install python3.10-venv # may not be necessary

• Make a local directory for the project

mkdir ~/AnalyticPiano && cd ~/AnalyticPiano

• Clone the app from Github

git clone --single-branch --branch main https://github.com/ospreyelm/HarmonyLab.git clone-of-main

• Setup virtual environment, watching out for and resolving any errors with pipenv lock

python3.10 -m venv apvenv
source apvenv/bin/activate
cd clone-of-main
# optional: run `pip install --upgrade pip`
pip install pipenv
pipenv lock
pipenv install

• Setup the database, having already installed postgresql

sudo service postgresql start # `service` on WSL2, otherwise `systemctl`
psql -U postgres
CREATE DATABASE analyticpiano;
\q

• Run the app locally as follows

cd ~/AnalyticPiano/clone-of-main
source ../apvenv/bin/activate
export DJANGO_SETTINGS_MODULE="harmony.settings.local"
./manage.py makemigrations
./manage.py migrate
./manage.py createsuperuser # optional: create admin account
./manage.py runserver

Open http://127.0.0.1:8000 in a browser, per terminal instructions (usually the keystroke to terminate the server is Ctrl+C). Remember to deactivate the virtual environment when you are done.

deactivate

Reminders for local development

• Certain changes to the app will require makemigrations and migrate to be run (see above).

• Any changes to Pipfile must be followed up with pipenv lock and pipenv install.

• Otherwise, for general use, the following command will suffice:

cd ~/AnalyticPiano/clone-of-main && source ../apvenv/bin/activate && export DJANGO_SETTINGS_MODULE="harmony.settings.local" && sudo service postgresql start && ./manage.py runserver

or on Ubuntu

cd ~/AnalyticPiano/clone-of-main && source ../apvenv/bin/activate && export DJANGO_SETTINGS_MODULE="harmony.settings.local" && sudo systemctl start postgresql.service && ./manage.py runserver

Using a local copy of a production database on WSL2

For WSL2 users who wish to run a local copy of a production database and access it via pgAdmin on Windows proper, locate and edit the config files:

psql -U postgres -c 'SHOW config_file'
sudo nano /etc/postgresql/13/main/pg_hba.conf # adapt this line as appropriate

—then edit the line under "Database administrative login," which should be the first line of settings, to show not peer but trust

local  all  postgres  trust

—then exit and save. Next:

sudo nano /etc/postgresql/13/main/postgresql.conf # adapt this line as appropriate

—then edit the listen_addresses value to "*" and exit and save. Finally for the command line:

sudo service postgresql restart

Now in pgAdmin, add a new server with the name wsl2 (for example) and the host address 127.0.0.1. The default username and password for postgres are postgres and password; enter these or the credentials you have setup via postgresql on WSL2. Create a backup from your production database and restore (in the role of postgres) this to a newly created database called analyticpiano on the wsl2 server. Make sure that the encoding of the backup matches that of the template database on WSL2 (probably SQL_ASCII); include all pre-data, data, and post-data; but omit owner, privilege, tablespace, unlogged table data, and comments.

analyticpiano's People

Contributors

arthurian avatar avnerdorman avatar dependabot[bot] avatar irwinli2014 avatar julian-george avatar myoneflag avatar ospreyelm avatar pouya-asghari777 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

analyticpiano's Issues

Fix exercise locking

Currently, exercises that have already been performed in a transposition are not being marked as locked. This presumably has something to do with the changes to transposition in the models. Figure out why performing a transposed exercise doesn't lock the exercise, fix it, and write a migration to search through PerformanceData for exercises that are erroneously unlocked and lock them.

Standardize datetime handling

Currently, some datetimes are handled by the builtin datetime module, others are handled by the external pytz module, and all of them kind of differ slightly, and there are a variety of methods and functions that deal with datetimes, many being legacy code. Ideally, there should be a method on the playlist/course model which is a single source of truth for all due dates and publish dates.

Better implementation of ordering field

Instead of hacking together the field with extensive and inflexible (and hacky) changes to the template, create a custom widget with custom javascript that would speed things up, improve flexibility, and allow for more intuitive behavior like drag and drop.

Allow for dynamic timezones

Currently, the app assumes all users and all admins are using EST, but that won't always be true. This issue consists of a few steps:

  • Ensure that the datetimes displayed to the user match their timezone. If a playlist is due at 23:59 EST, it should (for most days of the year) display as being due at 4:59 AM the next day for someone in the UK
  • Add the ability for course owners to change their course's master timezone. This would involve adding a new model & form field, along with changing all the settings.TIME_ZONE calls to match the time zone of their respective course.

Organize Migrations

  • Remove migration code that depends on variable model methods (properties not in the database itself)
  • Combine and rename migrations to streamline things

The goal should be to have migrations that function even if we had to delete the database and start fully from scratch with the current code in the repo.

Improve error handling

Improve error handling and stop returning general 500 errors for such situations as:

Course.DoesNotExist /ajax/exercise-performance/Z
Group.DoesNotExist /dashboard/courses/{course_id}/Z
Playlist.DoesNotExist /playlists/{course_id}/{playlist_id}/Z
User.DoesNotExist /exercises/add/Z

when an object has been deleted, when an exercise or playlist has been performed in preview, or when sometime attempts to add an exercise while not logged in, or similar situations.

Enharmonic respelling of the bass in (two-note) intervals when the key is none

Currently, the bass is not being respelled, though hEnharmonicAlterations returns the correct note name. To observe this behavior, choose "No key" and build two M3 intervals, first below Eb (which is respelled to D#) and second above Gb (which is not respelled to Ab as it should be). The analysis matches the staff notation, so there are no visible errors, but the "no key" environment is designed to interpret intervals as well as chords as simple diatonic objects, with appropriate respelling of the constituent pitches.

performance_dict data validity

  • Fix display of performances in instructor CourseActivityView, lots of erroneous readings
  • Figure out better enforcement/updating of performance_dict in cases such as playlist reordering, deletion, user data switching, subscribed group editing, etc... This will probably involve Django interceptors or similar query side effects

Clean up model methods

There's lots of methods/properties on each model that are either no longer used, inefficient, redundant, and almost all of them are poorly documented. To fix this, it'll be necessary to look through each model and carefully look through all the methods. This is an area where documentation would be key.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.