-
Notifications
You must be signed in to change notification settings - Fork 0
First update #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
petersen-f
wants to merge
2
commits into
main
Choose a base branch
from
first_update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
First update #3
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,322 @@ | ||
| { | ||
| "metadata": { | ||
| "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.6.6" | ||
| }, | ||
| "orig_nbformat": 2, | ||
| "kernelspec": { | ||
| "name": "python366jvsc74a57bd04fe30445ef53ac03b693547ad1486ea9656bbc56cc52e4778be38c3ffeb725e0", | ||
| "display_name": "Python 3.6.6 64-bit" | ||
| }, | ||
| "metadata": { | ||
| "interpreter": { | ||
| "hash": "4fe30445ef53ac03b693547ad1486ea9656bbc56cc52e4778be38c3ffeb725e0" | ||
| } | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 2, | ||
| "cells": [ | ||
| { | ||
| "source": [ | ||
| "This thingy will document stuff" | ||
| ], | ||
| "cell_type": "markdown", | ||
| "metadata": {} | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 23, | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "output_type": "execute_result", | ||
| "data": { | ||
| "text/plain": [ | ||
| "8" | ||
| ] | ||
| }, | ||
| "metadata": {}, | ||
| "execution_count": 23 | ||
| } | ||
| ], | ||
| "source": [ | ||
| "import pandas as pd\n", | ||
| "\n", | ||
| "data = {'key_number' :list(range(1,9)) }\n", | ||
| "\n", | ||
| "\n", | ||
| "key_bindings = pd.DataFrame(data)\n", | ||
| "key_bindings\n", | ||
| "len(key_bindings)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 1, | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "output_type": "stream", | ||
| "name": "stdout", | ||
| "text": [ | ||
| "pygame 1.9.6\nHello from the pygame community. https://www.pygame.org/contribute.html\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "from pygame import midi\n", | ||
| "\n", | ||
| "# initalise reading midi input\n", | ||
| "\n", | ||
| "midi.init()\n", | ||
| "\n", | ||
| "input = midi.Input(1)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 2, | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "output_type": "stream", | ||
| "name": "stdout", | ||
| "text": [ | ||
| "Please press key number 1\n", | ||
| "Please press key number 2\n", | ||
| "Please press key number 2\n", | ||
| "Please press key number 3\n", | ||
| "Please press key number 3\n", | ||
| "Please press key number 4\n", | ||
| "Please press key number 4\n", | ||
| "Please press key number 5\n", | ||
| "Please press key number 5\n", | ||
| "Please press key number 6\n", | ||
| "Please press key number 6\n", | ||
| "Please press key number 7\n", | ||
| "Please press key number 7\n", | ||
| "Please press key number 8\n", | ||
| "Please press key number 8\n", | ||
| "Thanks\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "key_id = list()\n", | ||
| "while True:\n", | ||
| " if input.poll():\n", | ||
| " print(\"Please press key number\",len(key_id)+1)\n", | ||
| " key = input.read(100)\n", | ||
| " key = key[0][0]\n", | ||
| " \n", | ||
| " key_num, sensitivity = key[1],key[2]\n", | ||
| "\n", | ||
| " if sensitivity !=0:\n", | ||
| " key_id.append(key_num)\n", | ||
| " \n", | ||
| " if len(key_id) ==8:\n", | ||
| " print(\"Thanks\")\n", | ||
| " break\n", | ||
| "\n" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 3, | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "output_type": "execute_result", | ||
| "data": { | ||
| "text/plain": [ | ||
| "[112, 113, 114, 115, 116, 117, 118, 119]" | ||
| ] | ||
| }, | ||
| "metadata": {}, | ||
| "execution_count": 3 | ||
| } | ||
| ], | ||
| "source": [ | ||
| "key_id" | ||
| ] | ||
| }, | ||
| { | ||
| "source": [ | ||
| "Nice now we need to add this column to the df we have created and print it" | ||
| ], | ||
| "cell_type": "markdown", | ||
| "metadata": {} | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 14, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "key_bindings.loc[:,\"key_id\"] = key_id\n", | ||
| "\n", | ||
| "key_bindings.to_csv(\"key_bindings.csv\")" | ||
| ] | ||
| }, | ||
| { | ||
| "source": [ | ||
| "# Next step" | ||
| ], | ||
| "cell_type": "markdown", | ||
| "metadata": {} | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 32, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "import os\n", | ||
| "\n", | ||
| "key_bindings = pd.read_csv('./key_bindings.csv')\n", | ||
| "\n", | ||
| "note_files = os.listdir('./Notes')\n", | ||
| "\n", | ||
| "key_bindings.loc[:,\"note_files\"] = note_files\n", | ||
| "\n", | ||
| "path = key_bindings.iloc[0,3]\n", | ||
| "\n", | ||
| "\n", | ||
| "from PIL import Image\n", | ||
| "\n", | ||
| "img = Image.open(\"./Notes/\" + path)\n", | ||
| "\n", | ||
| "img.show()\n" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 1, | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "output_type": "stream", | ||
| "name": "stdout", | ||
| "text": [ | ||
| "pygame 1.9.6\n", | ||
| "Hello from the pygame community. https://www.pygame.org/contribute.html\n", | ||
| "Please press key number 1\n" | ||
| ] | ||
| }, | ||
| { | ||
| "output_type": "error", | ||
| "ename": "IndexError", | ||
| "evalue": "list index out of range", | ||
| "traceback": [ | ||
| "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | ||
| "\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)", | ||
| "\u001b[1;32m<ipython-input-1-ad318990b60e>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpoll\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m100\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m!=\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 12\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Please press key number\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey_id\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 13\u001b[1;33m \u001b[0mkey\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m100\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 14\u001b[0m \u001b[1;31m#key = key\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | ||
| "\u001b[1;31mIndexError\u001b[0m: list index out of range" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "from pygame import midi\n", | ||
| "\n", | ||
| "# initalise reading midi input\n", | ||
| "\n", | ||
| "midi.init()\n", | ||
| "\n", | ||
| "input = midi.Input(1)\n", | ||
| "\n", | ||
| "key_id = list()\n", | ||
| "while True:\n", | ||
| " print(\"Please press key number\",len(key_id)+1)\n", | ||
| " if input.poll():\n", | ||
| " \n", | ||
| " print(\"Please press key number\",len(key_id)+1)\n", | ||
| " key = input.read(100)[0][0]\n", | ||
| " \n", | ||
| " #key_num, sensitivity = key[1],key[2]\n", | ||
| "\n", | ||
| " #if sensitivity !=0:\n", | ||
| " # print(\"Hi\")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 1, | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "output_type": "stream", | ||
| "name": "stdout", | ||
| "text": [ | ||
| "pygame 1.9.6\n", | ||
| "Hello from the pygame community. https://www.pygame.org/contribute.html\n", | ||
| "112\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "# This script will take the csv we produced last time and show a picture when a key is pressed down\n", | ||
| "\n", | ||
| "from PIL import Image\n", | ||
| "import pandas as pd\n", | ||
| "key_bindings = pd.read_csv('./key_bindings.csv')\n", | ||
| "\n", | ||
| "\n", | ||
| "from pygame import midi\n", | ||
| "\n", | ||
| "midi.init()\n", | ||
| "\n", | ||
| "input = midi.Input(1)\n", | ||
| "\n", | ||
| "\n", | ||
| "while True:\n", | ||
| " if input.poll():\n", | ||
| " midi_key = input.read(100)[0][0]\n", | ||
| " key_id, key_sensitivity = midi_key[1], midi_key[2]\n", | ||
| "\n", | ||
| " if key_sensitivity != 0:\n", | ||
| " print(key_id)\n", | ||
| " path = key_bindings.loc[key_bindings.loc[:,\"key_id\"] == key_id,\"note_files\"].item()\n", | ||
| " break\n" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 10, | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "output_type": "execute_result", | ||
| "data": { | ||
| "text/plain": [ | ||
| "'1_Treble_C4_Natural.png'" | ||
| ] | ||
| }, | ||
| "metadata": {}, | ||
| "execution_count": 10 | ||
| } | ||
| ], | ||
| "source": [ | ||
| "key_bindings.loc[key_bindings.loc[:,\"key_id\"] == key_id,\"note_files\"]\n", | ||
| "\n", | ||
| "key_bindings.loc[key_bindings[\"key_id\"]==key_id, \"note_files\"].item()" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [] | ||
| } | ||
| ] | ||
| } | ||
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not entirely sure what exactly this notebook does, so maybe it's a good idea to add some general explanation of what this notebook does at the top of the code? I am guessing that when you made this, you made it mostly for yourself and therefore didn't document a lot, which I also tend to do quite often... :(