{"action":"created","issue":{"url":"https://api.github.com/repos/libpd/libpd/issues/107","labels_url":"https://api.github.com/repos/libpd/libpd/issues/107/labels{/name}","comments_url":"https://api.github.com/repos/libpd/libpd/issues/107/comments","events_url":"https://api.github.com/repos/libpd/libpd/issues/107/events","html_url":"https://github.com/libpd/libpd/issues/107","id":109865570,"number":107,"title":"PyAudio & PdManager tick size and seg fault.","user":{"login":"monkeyswarm","id":1235083,"avatar_url":"https://avatars.githubusercontent.com/u/1235083?v=3","gravatar_id":"","url":"https://api.github.com/users/monkeyswarm","html_url":"https://github.com/monkeyswarm","followers_url":"https://api.github.com/users/monkeyswarm/followers","following_url":"https://api.github.com/users/monkeyswarm/following{/other_user}","gists_url":"https://api.github.com/users/monkeyswarm/gists{/gist_id}","starred_url":"https://api.github.com/users/monkeyswarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monkeyswarm/subscriptions","organizations_url":"https://api.github.com/users/monkeyswarm/orgs","repos_url":"https://api.github.com/users/monkeyswarm/repos","events_url":"https://api.github.com/users/monkeyswarm/events{/privacy}","received_events_url":"https://api.github.com/users/monkeyswarm/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-10-05T19:13:10Z","updated_at":"2015-10-19T18:55:23Z","closed_at":"2015-10-19T18:55:23Z","body":"Using PyAudio and libpd on a Raspberry Pi running Raspbian. I am using current version of PyAudio in the non-blocking \"callback\" mode, rather than in the blocking mode (which is used in the libpd examples).\r\n\r\nWhen I try to create a PdManager with a tick value of anything other than 1, I get a segmentation fault. \r\n(Setting it to a larger ticks-per-buffer value is necessary for computing buffer size of larger than 64.) Am I doing something wrong here? Or is this a PyAudio issue?\r\n\r\n```python\r\nfrom pylibpd import *\r\nimport pyaudio\r\nimport time\r\n\r\np = pyaudio.PyAudio()\r\n\r\nch = 1\r\nsr = 44100\r\ntpb = 1 # works fine when this is 1. Higher powers of 2 yield a segmentation fault.\r\nbs = libpd_blocksize()\r\n\r\nm = PdManager(0, ch, sr, tpb)\r\npatch = libpd_open_patch('test.pd', '.')\r\n\r\ndummyInputData = array.array('h', [0] * (bs * tpb))\r\n\r\ndef audio_callback(in_data, frame_count, time_info, status):\r\n    return (m.process(dummyInputData), pyaudio.paContinue)\r\n\r\nstream = p.open(format = pyaudio.paInt16,\r\n                           channels = ch,\r\n                           rate = sr,\r\n                           input = False,\r\n                           output = True,\r\n                           frames_per_buffer = bs * tpb,\r\n                           stream_callback = audio_callback)\r\n\r\nstream.start_stream()\r\n\r\nwhile stream.is_active():\r\n    time.sleep(0.1)\r\n\r\nstream.close()\r\np.terminate()\r\nlibpd_release\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/libpd/libpd/issues/comments/149311923","html_url":"https://github.com/libpd/libpd/issues/107#issuecomment-149311923","issue_url":"https://api.github.com/repos/libpd/libpd/issues/107","id":149311923,"user":{"login":"monkeyswarm","id":1235083,"avatar_url":"https://avatars.githubusercontent.com/u/1235083?v=3","gravatar_id":"","url":"https://api.github.com/users/monkeyswarm","html_url":"https://github.com/monkeyswarm","followers_url":"https://api.github.com/users/monkeyswarm/followers","following_url":"https://api.github.com/users/monkeyswarm/following{/other_user}","gists_url":"https://api.github.com/users/monkeyswarm/gists{/gist_id}","starred_url":"https://api.github.com/users/monkeyswarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monkeyswarm/subscriptions","organizations_url":"https://api.github.com/users/monkeyswarm/orgs","repos_url":"https://api.github.com/users/monkeyswarm/repos","events_url":"https://api.github.com/users/monkeyswarm/events{/privacy}","received_events_url":"https://api.github.com/users/monkeyswarm/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T18:55:23Z","updated_at":"2015-10-19T18:55:23Z","body":"Ha, didn't mean to make you the straw man here! \r\n\r\nNow that I understand it, I think leaving the logic-as-is is fine. It is up to users to take a (blocksize * ticks)-sized callback buffer from python, and iterate over that (tick) times with multiple calls to PdManager.process(). \r\n\r\nI had merely made the false assumption that since PdManager initialization took a tick parameter, that it processed a buffer size of (tick * block). \r\n\r\nI'll close this, but if anyone feels like revisiting, feel free to reopen. Thanks for checking, Dan."}}