{"action":"created","comment":{"url":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls/comments/112831592","pull_request_review_id":34177000,"id":112831592,"diff_hunk":"@@ -2349,6 +2376,125 @@ def __init__(self, channel_selectors):\n             channelSelectors=self._selectors))\n \n \n+class CoreAudioSettings(object):\n+\n+    def __init__(self, channel_map=None, change_device_parameters=False,\n+                 fail_if_conversion_required=False,\n+                 conversion_quality='Max'):\n+        \"\"\"Mac Core Audio-specific input/output settings.\n+\n+        Objects of this class can be used as *extra_settings* argument\n+        to `Stream()` (and variants) or as `default.extra_settings`.\n+\n+        Parameters\n+        ----------\n+        channel_map : array of int, optional\n+            Support for opening only specific channels of a MacCore\n+            device.  *channel_map* is a list of integers specifying the\n+            (zero-based) channel numbers to use.  Note that\n+            *channel_map* is treated differently between input and\n+            output channels.\n+\n+            For output devices, *channel_map* must have the same length\n+            as the number of channels of the device.  Initialize unused\n+            channels in this array with -1, and a 0-based index for any\n+            desired channels.  For an example 6-channel output device\n+            where an application wants to only write to the third and\n+            fourth channels, this array would be [-1, -1, 0, 1, -1, -1].\n+\n+            For input devices, *channel_map* is a list of integers\n+            specifying the (zero-based) channel numbers to use.  For an\n+            example 6-channel input device where the application wants\n+            to read from the third and fourth channels, this array would\n+            be [2, 3].\n+\n+            The example below demonstrates setting up for a 94-channel\n+            device.  For additional information, see\n+            https://app.assembla.com/spaces/portaudio/git/source/master/src/hostapi/coreaudio/notes.txt\n+        change_device_parameters : bool, optional\n+            If ``True``, allows PortAudio to change things like the\n+            device's frame size, which allows for much lower latency,\n+            but might disrupt the device if other programs are using it,\n+            even when you are just Querying the device.  ``False`` is\n+            the default.\n+        fail_if_conversion_required : bool, optional\n+            In combination with the above flag, ``True`` causes the\n+            stream opening to fail, unless the exact sample rates are\n+            supported by the device.\n+        conversion_quality : string, optional\n+            This sets MacCore's sample rate conversion quality.\n+            Possible values are: ``'Min'``, ``'Low'``, ``'Medium'``,\n+            ``'High'``, or ``'Max'``.  ``'Max'`` is the default.\n+\n+        Example\n+        -------\n+        This example assumes a device having 94 input and 94 output\n+        channels.  Input is from channels 8 and 9, and output will be\n+        sent to channels 2 and 3:\n+\n+        >>> import sounddevice as sd\n+        >>>\n+        >>> input_channels = [8, 9]\n+        >>> output_channels = [2, 3]\n+        >>>\n+        >>> # For input devices, the channel_map is simply the list of\n+        >>> # 0-based index numbers for each channel:\n+        >>> ch_map_in = input_channels\n+        >>> mc_in = sd.CoreAudioSettings(channel_map=ch_map_in)\n+        >>>\n+        >>> # For output devices, the list needs to be \"inverted\":\n+        >>> # Populate the array with -1 for unwanted channels:\n+        >>> info = query_devices(device, 'output')\n+        >>> max_output_channels = info['max_output_channels']\n+        >>> ch_map_out = [-1 for _ in range(max_output_channels)]\n+        >>> # For this example device, max_output_channels == 94.\n+        >>> # Now overwrite any -1's for channels we'll use for output:\n+        >>> for ndx in range(len(output_channels)):\n+        >>>     ch_map_out[output_channels[ndx]]=ndx\n+        >>> mc_out = sd.CoreAudioSettings(channel_map=ch_map_out)\n+        >>>\n+        >>> sd.playrec(..., channels=2, extra_settings=(mc_in, mc_out))\n+        \"\"\"\n+        # Check inputs:\n+        conversion_dict = {\n+            'Min':    _lib.paMacCoreConversionQualityMin,\n+            'Low':    _lib.paMacCoreConversionQualityLow,\n+            'Medium': _lib.paMacCoreConversionQualityMedium,\n+            'High':   _lib.paMacCoreConversionQualityHigh,\n+            'Max':    _lib.paMacCoreConversionQualityMax,\n+        }\n+\n+        if channel_map is not None:\n+            if isinstance(channel_map, int):\n+                raise TypeError('channel_map must be a list or tuple')\n+            if isinstance(channel_map, (list, tuple)) \\\n+                    and len(channel_map)==0:\n+                raise TypeError('channel_map may not be empty')\n+\n+        try:\n+            self._flags = conversion_dict[conversion_quality]\n+        except KeyError:\n+            raise ValueError(","path":"sounddevice.py","position":null,"original_position":145,"commit_id":"d4a7bdd0318e6fdaac8f3eb4d72166d5bde73826","original_commit_id":"380e225d71b7574c22968673498ac8a030513b48","user":{"login":"mgeier","id":705404,"avatar_url":"https://avatars2.githubusercontent.com/u/705404?v=3","gravatar_id":"","url":"https://api.github.com/users/mgeier","html_url":"https://github.com/mgeier","followers_url":"https://api.github.com/users/mgeier/followers","following_url":"https://api.github.com/users/mgeier/following{/other_user}","gists_url":"https://api.github.com/users/mgeier/gists{/gist_id}","starred_url":"https://api.github.com/users/mgeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgeier/subscriptions","organizations_url":"https://api.github.com/users/mgeier/orgs","repos_url":"https://api.github.com/users/mgeier/repos","events_url":"https://api.github.com/users/mgeier/events{/privacy}","received_events_url":"https://api.github.com/users/mgeier/received_events","type":"User","site_admin":false},"body":"It is 79 columns, 72 is only suggested for docstrings.\r\n\r\nI was thinking of\r\n\r\n```python\r\n            raise ValueError('conversion_quality must be one of {0!r}'.format(\r\n                list(conversion_dict.keys())))\r\n```\r\n\r\nOr does this violate any guidelines?\r\n\r\nI just realized that `.keys()` is unnecessary, so it would be\r\n\r\n```python\r\n            raise ValueError('conversion_quality must be one of {0!r}'.format(\r\n                list(conversion_dict)))\r\n```\r\n\r\nOh, and the `!r` isn't necessary either, right?\r\n\r\n```python\r\n            raise ValueError('conversion_quality must be one of {0}'.format(\r\n                list(conversion_dict)))\r\n```\r\n\r\nAnd a single replacement without specific formatting at the end of the string is kinda strange, right?\r\nYet another option would be\r\n\r\n```python\r\n            raise ValueError('conversion_quality must be one of ' +\r\n                             repr(list(conversion_dict)))\r\n```","created_at":"2017-04-23T11:37:06Z","updated_at":"2017-04-23T11:37:06Z","html_url":"https://github.com/spatialaudio/python-sounddevice/pull/83#discussion_r112831592","pull_request_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls/83","_links":{"self":{"href":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls/comments/112831592"},"html":{"href":"https://github.com/spatialaudio/python-sounddevice/pull/83#discussion_r112831592"},"pull_request":{"href":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls/83"}}},"pull_request":{"url":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls/83","id":116029050,"html_url":"https://github.com/spatialaudio/python-sounddevice/pull/83","diff_url":"https://github.com/spatialaudio/python-sounddevice/pull/83.diff","patch_url":"https://github.com/spatialaudio/python-sounddevice/pull/83.patch","issue_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/issues/83","number":83,"state":"open","locked":false,"title":"Core Audio for interfaces with large #'s of channels","user":{"login":"dholl","id":4298582,"avatar_url":"https://avatars3.githubusercontent.com/u/4298582?v=3","gravatar_id":"","url":"https://api.github.com/users/dholl","html_url":"https://github.com/dholl","followers_url":"https://api.github.com/users/dholl/followers","following_url":"https://api.github.com/users/dholl/following{/other_user}","gists_url":"https://api.github.com/users/dholl/gists{/gist_id}","starred_url":"https://api.github.com/users/dholl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dholl/subscriptions","organizations_url":"https://api.github.com/users/dholl/orgs","repos_url":"https://api.github.com/users/dholl/repos","events_url":"https://api.github.com/users/dholl/events{/privacy}","received_events_url":"https://api.github.com/users/dholl/received_events","type":"User","site_admin":false},"body":"These 3 commits access PA's Core Audio API from pa_mac_core.h, and provide a \"get_channel_name\" function for querying names of individual device channels along with MacCoreSettings (for use with extra_settings) to expose additional Core Audio capabilities.  (See doc string in MacCoreSettings.)\r\n\r\nMy specific need for these extensions is that I have an RME Fireface UFX+ with a large number of input & output channels, and I didn't want to have to open many channels when only a couple are required.  The get_channel_name function lets me display obtain a set of user-friendly channel names from the underlying device driver (via PortAudio), which I may display to the operator / user.\r\n\r\nI'm open for input to help get these changes incorporated into python-sounddevice.\r\n\r\nThank you,\r\nDavid","created_at":"2017-04-15T15:36:37Z","updated_at":"2017-04-23T11:37:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2af9a05d3de8afa14239e8d65e0156feacfebec0","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls/83/commits","review_comments_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls/83/comments","review_comment_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/issues/83/comments","statuses_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/statuses/d4a7bdd0318e6fdaac8f3eb4d72166d5bde73826","head":{"label":"dholl:master","ref":"master","sha":"d4a7bdd0318e6fdaac8f3eb4d72166d5bde73826","user":{"login":"dholl","id":4298582,"avatar_url":"https://avatars3.githubusercontent.com/u/4298582?v=3","gravatar_id":"","url":"https://api.github.com/users/dholl","html_url":"https://github.com/dholl","followers_url":"https://api.github.com/users/dholl/followers","following_url":"https://api.github.com/users/dholl/following{/other_user}","gists_url":"https://api.github.com/users/dholl/gists{/gist_id}","starred_url":"https://api.github.com/users/dholl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dholl/subscriptions","organizations_url":"https://api.github.com/users/dholl/orgs","repos_url":"https://api.github.com/users/dholl/repos","events_url":"https://api.github.com/users/dholl/events{/privacy}","received_events_url":"https://api.github.com/users/dholl/received_events","type":"User","site_admin":false},"repo":{"id":88353882,"name":"python-sounddevice","full_name":"dholl/python-sounddevice","owner":{"login":"dholl","id":4298582,"avatar_url":"https://avatars3.githubusercontent.com/u/4298582?v=3","gravatar_id":"","url":"https://api.github.com/users/dholl","html_url":"https://github.com/dholl","followers_url":"https://api.github.com/users/dholl/followers","following_url":"https://api.github.com/users/dholl/following{/other_user}","gists_url":"https://api.github.com/users/dholl/gists{/gist_id}","starred_url":"https://api.github.com/users/dholl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dholl/subscriptions","organizations_url":"https://api.github.com/users/dholl/orgs","repos_url":"https://api.github.com/users/dholl/repos","events_url":"https://api.github.com/users/dholl/events{/privacy}","received_events_url":"https://api.github.com/users/dholl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dholl/python-sounddevice","description":":sound: Play and Record Sound with Python :snake:","fork":true,"url":"https://api.github.com/repos/dholl/python-sounddevice","forks_url":"https://api.github.com/repos/dholl/python-sounddevice/forks","keys_url":"https://api.github.com/repos/dholl/python-sounddevice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dholl/python-sounddevice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dholl/python-sounddevice/teams","hooks_url":"https://api.github.com/repos/dholl/python-sounddevice/hooks","issue_events_url":"https://api.github.com/repos/dholl/python-sounddevice/issues/events{/number}","events_url":"https://api.github.com/repos/dholl/python-sounddevice/events","assignees_url":"https://api.github.com/repos/dholl/python-sounddevice/assignees{/user}","branches_url":"https://api.github.com/repos/dholl/python-sounddevice/branches{/branch}","tags_url":"https://api.github.com/repos/dholl/python-sounddevice/tags","blobs_url":"https://api.github.com/repos/dholl/python-sounddevice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dholl/python-sounddevice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dholl/python-sounddevice/git/refs{/sha}","trees_url":"https://api.github.com/repos/dholl/python-sounddevice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dholl/python-sounddevice/statuses/{sha}","languages_url":"https://api.github.com/repos/dholl/python-sounddevice/languages","stargazers_url":"https://api.github.com/repos/dholl/python-sounddevice/stargazers","contributors_url":"https://api.github.com/repos/dholl/python-sounddevice/contributors","subscribers_url":"https://api.github.com/repos/dholl/python-sounddevice/subscribers","subscription_url":"https://api.github.com/repos/dholl/python-sounddevice/subscription","commits_url":"https://api.github.com/repos/dholl/python-sounddevice/commits{/sha}","git_commits_url":"https://api.github.com/repos/dholl/python-sounddevice/git/commits{/sha}","comments_url":"https://api.github.com/repos/dholl/python-sounddevice/comments{/number}","issue_comment_url":"https://api.github.com/repos/dholl/python-sounddevice/issues/comments{/number}","contents_url":"https://api.github.com/repos/dholl/python-sounddevice/contents/{+path}","compare_url":"https://api.github.com/repos/dholl/python-sounddevice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dholl/python-sounddevice/merges","archive_url":"https://api.github.com/repos/dholl/python-sounddevice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dholl/python-sounddevice/downloads","issues_url":"https://api.github.com/repos/dholl/python-sounddevice/issues{/number}","pulls_url":"https://api.github.com/repos/dholl/python-sounddevice/pulls{/number}","milestones_url":"https://api.github.com/repos/dholl/python-sounddevice/milestones{/number}","notifications_url":"https://api.github.com/repos/dholl/python-sounddevice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dholl/python-sounddevice/labels{/name}","releases_url":"https://api.github.com/repos/dholl/python-sounddevice/releases{/id}","deployments_url":"https://api.github.com/repos/dholl/python-sounddevice/deployments","created_at":"2017-04-15T14:57:06Z","updated_at":"2017-04-15T14:57:07Z","pushed_at":"2017-04-23T08:11:14Z","git_url":"git://github.com/dholl/python-sounddevice.git","ssh_url":"git@github.com:dholl/python-sounddevice.git","clone_url":"https://github.com/dholl/python-sounddevice.git","svn_url":"https://github.com/dholl/python-sounddevice","homepage":"http://python-sounddevice.rtfd.io/","size":392,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"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":"spatialaudio:master","ref":"master","sha":"1ceba2671c0a572e78170a9049b8d230bdc67685","user":{"login":"spatialaudio","id":7491513,"avatar_url":"https://avatars2.githubusercontent.com/u/7491513?v=3","gravatar_id":"","url":"https://api.github.com/users/spatialaudio","html_url":"https://github.com/spatialaudio","followers_url":"https://api.github.com/users/spatialaudio/followers","following_url":"https://api.github.com/users/spatialaudio/following{/other_user}","gists_url":"https://api.github.com/users/spatialaudio/gists{/gist_id}","starred_url":"https://api.github.com/users/spatialaudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spatialaudio/subscriptions","organizations_url":"https://api.github.com/users/spatialaudio/orgs","repos_url":"https://api.github.com/users/spatialaudio/repos","events_url":"https://api.github.com/users/spatialaudio/events{/privacy}","received_events_url":"https://api.github.com/users/spatialaudio/received_events","type":"Organization","site_admin":false},"repo":{"id":37774726,"name":"python-sounddevice","full_name":"spatialaudio/python-sounddevice","owner":{"login":"spatialaudio","id":7491513,"avatar_url":"https://avatars2.githubusercontent.com/u/7491513?v=3","gravatar_id":"","url":"https://api.github.com/users/spatialaudio","html_url":"https://github.com/spatialaudio","followers_url":"https://api.github.com/users/spatialaudio/followers","following_url":"https://api.github.com/users/spatialaudio/following{/other_user}","gists_url":"https://api.github.com/users/spatialaudio/gists{/gist_id}","starred_url":"https://api.github.com/users/spatialaudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spatialaudio/subscriptions","organizations_url":"https://api.github.com/users/spatialaudio/orgs","repos_url":"https://api.github.com/users/spatialaudio/repos","events_url":"https://api.github.com/users/spatialaudio/events{/privacy}","received_events_url":"https://api.github.com/users/spatialaudio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spatialaudio/python-sounddevice","description":":sound: Play and Record Sound with Python :snake:","fork":false,"url":"https://api.github.com/repos/spatialaudio/python-sounddevice","forks_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/forks","keys_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/teams","hooks_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/hooks","issue_events_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/issues/events{/number}","events_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/events","assignees_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/assignees{/user}","branches_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/branches{/branch}","tags_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/tags","blobs_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/git/refs{/sha}","trees_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/statuses/{sha}","languages_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/languages","stargazers_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/stargazers","contributors_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/contributors","subscribers_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/subscribers","subscription_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/subscription","commits_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/commits{/sha}","git_commits_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/git/commits{/sha}","comments_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/comments{/number}","issue_comment_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/issues/comments{/number}","contents_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/contents/{+path}","compare_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/merges","archive_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/downloads","issues_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/issues{/number}","pulls_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls{/number}","milestones_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/milestones{/number}","notifications_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/labels{/name}","releases_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/releases{/id}","deployments_url":"https://api.github.com/repos/spatialaudio/python-sounddevice/deployments","created_at":"2015-06-20T15:34:00Z","updated_at":"2017-04-08T15:56:19Z","pushed_at":"2017-04-23T08:11:15Z","git_url":"git://github.com/spatialaudio/python-sounddevice.git","ssh_url":"git@github.com:spatialaudio/python-sounddevice.git","clone_url":"https://github.com/spatialaudio/python-sounddevice.git","svn_url":"https://github.com/spatialaudio/python-sounddevice","homepage":"http://python-sounddevice.rtfd.io/","size":243,"stargazers_count":85,"watchers_count":85,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":24,"forks":20,"open_issues":24,"watchers":85,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls/83"},"html":{"href":"https://github.com/spatialaudio/python-sounddevice/pull/83"},"issue":{"href":"https://api.github.com/repos/spatialaudio/python-sounddevice/issues/83"},"comments":{"href":"https://api.github.com/repos/spatialaudio/python-sounddevice/issues/83/comments"},"review_comments":{"href":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls/83/comments"},"review_comment":{"href":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spatialaudio/python-sounddevice/pulls/83/commits"},"statuses":{"href":"https://api.github.com/repos/spatialaudio/python-sounddevice/statuses/d4a7bdd0318e6fdaac8f3eb4d72166d5bde73826"}}}}
{"actor":{"display_login":"mgeier"}}