{ "cells": [ { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from pathlib import Path\n", "import json\n", "\n", "BASE_PATH= \"../\"" ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [], "source": [ "#get a list of performances such as there are not 2 performances of the same piece\n", "df = pd.read_csv(Path(BASE_PATH,\"metadata.csv\"))\n", "unique_df = df.drop_duplicates(subset=[\"title\",\"composer\"])\n", "unique_performance_list = unique_df[\"midi_performance\"].tolist()\n", "\n", "#get the downbeat_list of a performance of Bach Fugue_bwv_848\n", "midi_path = df.loc[df.title==\"Fugue_bwv_848\",\"midi_performance\"].iloc[0]\n", "with open(Path('../asap_annotations.json')) as json_file:\n", " json_data = json.load(json_file)\n", "db_list = json_data[midi_path][\"performance_downbeats\"]\n", "\n", "#same task, but using the TSV file\n", "annotation_path = df.loc[df.title==\"Fugue_bwv_848\",\"performance_annotations\"].iloc[0]\n", "ann_df = pd.read_csv(Path(BASE_PATH,annotation_path),header=None, names=[\"time\",\"time2\",\"type\"],sep='\\t')\n", "db_list = [row[\"time\"] for i,row in ann_df.iterrows() if row[\"type\"].split(\",\")[0]==\"db\"]\n", "\n", "#get all pieces with time signature changes\n", "with open(Path('../asap_annotations.json')) as json_file:\n", " json_data = json.load(json_file)\n", "tsc_pieces = [p for p in json_data.keys() if len(json_data[p][\"perf_time_signatures\"])>1 ]" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1039" ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#get all pieces where the score is aligned to the performance\n", "with open(Path('../asap_annotations.json')) as json_file:\n", " json_data = json.load(json_file)\n", "aligned_pieces = [p for p in json_data.keys() if json_data[p][\"score_and_performance_aligned\"] ]\n", "len(aligned_pieces)" ] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "29" ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1068-1039" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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", "version": "3.7.7" } }, "nbformat": 4, "nbformat_minor": 4 }