{"action":"created","comment":{"url":"https://api.github.com/repos/tensorflow/magenta/pulls/comments/78406931","id":78406931,"diff_hunk":"@@ -498,48 +516,216 @@ def stop_capture(self):\n     return self.captured_sequence\n \n   @serialized\n-  def wait_for_control_signal(self, control_number, control_value=None):\n+  def wait_for_control_signal(self, control_message):\n     \"\"\"Blocks until a specific control signal arrives.\n-\n     Args:\n-      control_number: The integer control change number.\n-      control_value: The integer control change value or None if any is\n-         acceptable.\n-\n+      control_message: The control change message.\n     \"\"\"\n     if self._inport.callback is None:\n-      # Not in a capture session.\n+      # No callback set for inport\n       for msg in self._inport:\n-        if (msg.type == 'control_change' and msg.control == control_number and\n-            (control_value is None or msg.value == control_value)):\n+        if msg.hex()[:5] == control_message.hex()[:5] and msg.type == 'note_on':\n+          if msg.velocity != 0:\n+            msg = msg.copy(velocity=1)\n+        if msg.hex() == control_message.hex():\n           return\n     else:\n-      # In a capture session.\n-      control_tuple = ((control_number,) if control_value is None else\n-                       (control_number, control_value))\n-      if control_tuple not in self._control_cvs:\n-        self._control_cvs[control_tuple] = threading.Condition(self._lock)\n-      self._control_cvs[control_tuple].wait()\n-\n-  def start_playback(self, sequence, metronome_velocity):\n+      # In a capture session\n+      if control_message.hex() not in self._control_cvs:\n+        self._control_cvs[control_message.hex()] = threading.Condition(\n+          self._lock)\n+      self._control_cvs[control_message.hex()].wait()\n+\n+  def start_playback(self, sequence):\n     \"\"\"Plays the monophonic, sorted NoteSequence through the MIDI output port.\n \n     Stops any previously playing sequences.\n \n     Args:\n       sequence: The monohponic, chronologically sorted NoteSequence to play.\n-      metronome_velocity: The velocity of the metronome's MIDI note_on message.\n     \"\"\"\n     self.stop_playback()\n-    self._player = MonoMidiPlayer(self._outport, sequence, metronome_velocity)\n+    self._player = MonoMidiPlayer(self._outport, sequence)\n     self._player.start()\n+    self._inport.callback = self._capture_message\n \n   def stop_playback(self):\n     \"\"\"Stops any active sequence playback.\"\"\"\n     if self._player is not None and self._player.is_alive():\n       self._player.stop()\n       stdout_write_and_flush('Stopped\\n')\n \n+  def execute_cc_message(self, message):\n+    \"\"\"Defines how to treat non Start/Stop user defined CC messages.\n+\n+    Args:\n+      message: The incoming Control Change message.\n+    \"\"\"\n+\n+    # Metronome Velocity\n+    if message.bytes()[:2] == _CC_MAP['Metronome velocity'].bytes()[:2]:\n+      global _METRONOME_VELOCITY","path":"magenta/interfaces/midi/midi.py","position":327,"original_position":327,"commit_id":"23b775fe695f914449d738c4e11817a65587fc8f","original_commit_id":"23b775fe695f914449d738c4e11817a65587fc8f","user":{"login":"adarob","id":1088232,"avatar_url":"https://avatars.githubusercontent.com/u/1088232?v=3","gravatar_id":"","url":"https://api.github.com/users/adarob","html_url":"https://github.com/adarob","followers_url":"https://api.github.com/users/adarob/followers","following_url":"https://api.github.com/users/adarob/following{/other_user}","gists_url":"https://api.github.com/users/adarob/gists{/gist_id}","starred_url":"https://api.github.com/users/adarob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adarob/subscriptions","organizations_url":"https://api.github.com/users/adarob/orgs","repos_url":"https://api.github.com/users/adarob/repos","events_url":"https://api.github.com/users/adarob/events{/privacy}","received_events_url":"https://api.github.com/users/adarob/received_events","type":"User","site_admin":false},"body":"Let's not use globals. Instead you can have an object that gets passed around that has the current values of these variables. We can discuss offliine.","created_at":"2016-09-12T16:34:01Z","updated_at":"2016-09-12T16:34:01Z","html_url":"https://github.com/tensorflow/magenta/pull/209#discussion_r78406931","pull_request_url":"https://api.github.com/repos/tensorflow/magenta/pulls/209","_links":{"self":{"href":"https://api.github.com/repos/tensorflow/magenta/pulls/comments/78406931"},"html":{"href":"https://github.com/tensorflow/magenta/pull/209#discussion_r78406931"},"pull_request":{"href":"https://api.github.com/repos/tensorflow/magenta/pulls/209"}}},"pull_request":{"url":"https://api.github.com/repos/tensorflow/magenta/pulls/209","id":84812223,"html_url":"https://github.com/tensorflow/magenta/pull/209","diff_url":"https://github.com/tensorflow/magenta/pull/209.diff","patch_url":"https://github.com/tensorflow/magenta/pull/209.patch","issue_url":"https://api.github.com/repos/tensorflow/magenta/issues/209","number":209,"state":"open","locked":false,"title":"CC Map and interface","user":{"login":"hanzorama","id":16696309,"avatar_url":"https://avatars.githubusercontent.com/u/16696309?v=3","gravatar_id":"","url":"https://api.github.com/users/hanzorama","html_url":"https://github.com/hanzorama","followers_url":"https://api.github.com/users/hanzorama/followers","following_url":"https://api.github.com/users/hanzorama/following{/other_user}","gists_url":"https://api.github.com/users/hanzorama/gists{/gist_id}","starred_url":"https://api.github.com/users/hanzorama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanzorama/subscriptions","organizations_url":"https://api.github.com/users/hanzorama/orgs","repos_url":"https://api.github.com/users/hanzorama/repos","events_url":"https://api.github.com/users/hanzorama/events{/privacy}","received_events_url":"https://api.github.com/users/hanzorama/received_events","type":"User","site_admin":false},"body":"Allows user definition for start/stop capture messages, metronome velocity changes via CC, and changes structure to allow easy addition of other user definable CC parameters.","created_at":"2016-09-12T03:47:29Z","updated_at":"2016-09-12T16:34:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f6cfb3dd8b12c2d23b1d142397dd1da0b43ec4b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tensorflow/magenta/pulls/209/commits","review_comments_url":"https://api.github.com/repos/tensorflow/magenta/pulls/209/comments","review_comment_url":"https://api.github.com/repos/tensorflow/magenta/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tensorflow/magenta/issues/209/comments","statuses_url":"https://api.github.com/repos/tensorflow/magenta/statuses/23b775fe695f914449d738c4e11817a65587fc8f","head":{"label":"hanzorama:interactive_cc","ref":"interactive_cc","sha":"23b775fe695f914449d738c4e11817a65587fc8f","user":{"login":"hanzorama","id":16696309,"avatar_url":"https://avatars.githubusercontent.com/u/16696309?v=3","gravatar_id":"","url":"https://api.github.com/users/hanzorama","html_url":"https://github.com/hanzorama","followers_url":"https://api.github.com/users/hanzorama/followers","following_url":"https://api.github.com/users/hanzorama/following{/other_user}","gists_url":"https://api.github.com/users/hanzorama/gists{/gist_id}","starred_url":"https://api.github.com/users/hanzorama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanzorama/subscriptions","organizations_url":"https://api.github.com/users/hanzorama/orgs","repos_url":"https://api.github.com/users/hanzorama/repos","events_url":"https://api.github.com/users/hanzorama/events{/privacy}","received_events_url":"https://api.github.com/users/hanzorama/received_events","type":"User","site_admin":false},"repo":{"id":65040957,"name":"magenta","full_name":"hanzorama/magenta","owner":{"login":"hanzorama","id":16696309,"avatar_url":"https://avatars.githubusercontent.com/u/16696309?v=3","gravatar_id":"","url":"https://api.github.com/users/hanzorama","html_url":"https://github.com/hanzorama","followers_url":"https://api.github.com/users/hanzorama/followers","following_url":"https://api.github.com/users/hanzorama/following{/other_user}","gists_url":"https://api.github.com/users/hanzorama/gists{/gist_id}","starred_url":"https://api.github.com/users/hanzorama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanzorama/subscriptions","organizations_url":"https://api.github.com/users/hanzorama/orgs","repos_url":"https://api.github.com/users/hanzorama/repos","events_url":"https://api.github.com/users/hanzorama/events{/privacy}","received_events_url":"https://api.github.com/users/hanzorama/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hanzorama/magenta","description":"Magenta: Music and Art Generation with Machine Intelligence","fork":true,"url":"https://api.github.com/repos/hanzorama/magenta","forks_url":"https://api.github.com/repos/hanzorama/magenta/forks","keys_url":"https://api.github.com/repos/hanzorama/magenta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hanzorama/magenta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hanzorama/magenta/teams","hooks_url":"https://api.github.com/repos/hanzorama/magenta/hooks","issue_events_url":"https://api.github.com/repos/hanzorama/magenta/issues/events{/number}","events_url":"https://api.github.com/repos/hanzorama/magenta/events","assignees_url":"https://api.github.com/repos/hanzorama/magenta/assignees{/user}","branches_url":"https://api.github.com/repos/hanzorama/magenta/branches{/branch}","tags_url":"https://api.github.com/repos/hanzorama/magenta/tags","blobs_url":"https://api.github.com/repos/hanzorama/magenta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hanzorama/magenta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hanzorama/magenta/git/refs{/sha}","trees_url":"https://api.github.com/repos/hanzorama/magenta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hanzorama/magenta/statuses/{sha}","languages_url":"https://api.github.com/repos/hanzorama/magenta/languages","stargazers_url":"https://api.github.com/repos/hanzorama/magenta/stargazers","contributors_url":"https://api.github.com/repos/hanzorama/magenta/contributors","subscribers_url":"https://api.github.com/repos/hanzorama/magenta/subscribers","subscription_url":"https://api.github.com/repos/hanzorama/magenta/subscription","commits_url":"https://api.github.com/repos/hanzorama/magenta/commits{/sha}","git_commits_url":"https://api.github.com/repos/hanzorama/magenta/git/commits{/sha}","comments_url":"https://api.github.com/repos/hanzorama/magenta/comments{/number}","issue_comment_url":"https://api.github.com/repos/hanzorama/magenta/issues/comments{/number}","contents_url":"https://api.github.com/repos/hanzorama/magenta/contents/{+path}","compare_url":"https://api.github.com/repos/hanzorama/magenta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hanzorama/magenta/merges","archive_url":"https://api.github.com/repos/hanzorama/magenta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hanzorama/magenta/downloads","issues_url":"https://api.github.com/repos/hanzorama/magenta/issues{/number}","pulls_url":"https://api.github.com/repos/hanzorama/magenta/pulls{/number}","milestones_url":"https://api.github.com/repos/hanzorama/magenta/milestones{/number}","notifications_url":"https://api.github.com/repos/hanzorama/magenta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hanzorama/magenta/labels{/name}","releases_url":"https://api.github.com/repos/hanzorama/magenta/releases{/id}","deployments_url":"https://api.github.com/repos/hanzorama/magenta/deployments","created_at":"2016-08-05T18:36:37Z","updated_at":"2016-08-05T18:36:38Z","pushed_at":"2016-09-12T04:37:11Z","git_url":"git://github.com/hanzorama/magenta.git","ssh_url":"git@github.com:hanzorama/magenta.git","clone_url":"https://github.com/hanzorama/magenta.git","svn_url":"https://github.com/hanzorama/magenta","homepage":"","size":11272,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tensorflow:master","ref":"master","sha":"1e4ca2f57cb7e998bff448c11d88600dfccfa46c","user":{"login":"tensorflow","id":15658638,"avatar_url":"https://avatars.githubusercontent.com/u/15658638?v=3","gravatar_id":"","url":"https://api.github.com/users/tensorflow","html_url":"https://github.com/tensorflow","followers_url":"https://api.github.com/users/tensorflow/followers","following_url":"https://api.github.com/users/tensorflow/following{/other_user}","gists_url":"https://api.github.com/users/tensorflow/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflow/subscriptions","organizations_url":"https://api.github.com/users/tensorflow/orgs","repos_url":"https://api.github.com/users/tensorflow/repos","events_url":"https://api.github.com/users/tensorflow/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflow/received_events","type":"Organization","site_admin":false},"repo":{"id":58157629,"name":"magenta","full_name":"tensorflow/magenta","owner":{"login":"tensorflow","id":15658638,"avatar_url":"https://avatars.githubusercontent.com/u/15658638?v=3","gravatar_id":"","url":"https://api.github.com/users/tensorflow","html_url":"https://github.com/tensorflow","followers_url":"https://api.github.com/users/tensorflow/followers","following_url":"https://api.github.com/users/tensorflow/following{/other_user}","gists_url":"https://api.github.com/users/tensorflow/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflow/subscriptions","organizations_url":"https://api.github.com/users/tensorflow/orgs","repos_url":"https://api.github.com/users/tensorflow/repos","events_url":"https://api.github.com/users/tensorflow/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflow/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tensorflow/magenta","description":"Magenta: Music and Art Generation with Machine Intelligence","fork":false,"url":"https://api.github.com/repos/tensorflow/magenta","forks_url":"https://api.github.com/repos/tensorflow/magenta/forks","keys_url":"https://api.github.com/repos/tensorflow/magenta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tensorflow/magenta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tensorflow/magenta/teams","hooks_url":"https://api.github.com/repos/tensorflow/magenta/hooks","issue_events_url":"https://api.github.com/repos/tensorflow/magenta/issues/events{/number}","events_url":"https://api.github.com/repos/tensorflow/magenta/events","assignees_url":"https://api.github.com/repos/tensorflow/magenta/assignees{/user}","branches_url":"https://api.github.com/repos/tensorflow/magenta/branches{/branch}","tags_url":"https://api.github.com/repos/tensorflow/magenta/tags","blobs_url":"https://api.github.com/repos/tensorflow/magenta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tensorflow/magenta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tensorflow/magenta/git/refs{/sha}","trees_url":"https://api.github.com/repos/tensorflow/magenta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tensorflow/magenta/statuses/{sha}","languages_url":"https://api.github.com/repos/tensorflow/magenta/languages","stargazers_url":"https://api.github.com/repos/tensorflow/magenta/stargazers","contributors_url":"https://api.github.com/repos/tensorflow/magenta/contributors","subscribers_url":"https://api.github.com/repos/tensorflow/magenta/subscribers","subscription_url":"https://api.github.com/repos/tensorflow/magenta/subscription","commits_url":"https://api.github.com/repos/tensorflow/magenta/commits{/sha}","git_commits_url":"https://api.github.com/repos/tensorflow/magenta/git/commits{/sha}","comments_url":"https://api.github.com/repos/tensorflow/magenta/comments{/number}","issue_comment_url":"https://api.github.com/repos/tensorflow/magenta/issues/comments{/number}","contents_url":"https://api.github.com/repos/tensorflow/magenta/contents/{+path}","compare_url":"https://api.github.com/repos/tensorflow/magenta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tensorflow/magenta/merges","archive_url":"https://api.github.com/repos/tensorflow/magenta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tensorflow/magenta/downloads","issues_url":"https://api.github.com/repos/tensorflow/magenta/issues{/number}","pulls_url":"https://api.github.com/repos/tensorflow/magenta/pulls{/number}","milestones_url":"https://api.github.com/repos/tensorflow/magenta/milestones{/number}","notifications_url":"https://api.github.com/repos/tensorflow/magenta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tensorflow/magenta/labels{/name}","releases_url":"https://api.github.com/repos/tensorflow/magenta/releases{/id}","deployments_url":"https://api.github.com/repos/tensorflow/magenta/deployments","created_at":"2016-05-05T20:10:40Z","updated_at":"2016-09-12T16:10:37Z","pushed_at":"2016-09-12T16:27:02Z","git_url":"git://github.com/tensorflow/magenta.git","ssh_url":"git@github.com:tensorflow/magenta.git","clone_url":"https://github.com/tensorflow/magenta.git","svn_url":"https://github.com/tensorflow/magenta","homepage":"","size":14975,"stargazers_count":3172,"watchers_count":3172,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":355,"mirror_url":null,"open_issues_count":10,"forks":355,"open_issues":10,"watchers":3172,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tensorflow/magenta/pulls/209"},"html":{"href":"https://github.com/tensorflow/magenta/pull/209"},"issue":{"href":"https://api.github.com/repos/tensorflow/magenta/issues/209"},"comments":{"href":"https://api.github.com/repos/tensorflow/magenta/issues/209/comments"},"review_comments":{"href":"https://api.github.com/repos/tensorflow/magenta/pulls/209/comments"},"review_comment":{"href":"https://api.github.com/repos/tensorflow/magenta/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tensorflow/magenta/pulls/209/commits"},"statuses":{"href":"https://api.github.com/repos/tensorflow/magenta/statuses/23b775fe695f914449d738c4e11817a65587fc8f"}}}}
{"actor":{"display_login":"adarob"}}