File size: 3,230 Bytes
151b875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{
 "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
}