René's URL Explorer Experiment


Title: Detecting xruns in process callback · Issue #81 · spatialaudio/jackclient-python · GitHub

Open Graph Title: Detecting xruns in process callback · Issue #81 · spatialaudio/jackclient-python

X Title: Detecting xruns in process callback · Issue #81 · spatialaudio/jackclient-python

Description: Hi and thanks for the great library, been using it for years! What's the best way to detect if the last process callback lead to an xrun? Here's my use case: I'm sending MIDI, which works 99% of the time. But when an xrun occurs, the MID...

Open Graph Description: Hi and thanks for the great library, been using it for years! What's the best way to detect if the last process callback lead to an xrun? Here's my use case: I'm sending MIDI, which works 99% of th...

X Description: Hi and thanks for the great library, been using it for years! What's the best way to detect if the last process callback lead to an xrun? Here's my use case: I'm sending MIDI, which wor...

Opengraph URL: https://github.com/spatialaudio/jackclient-python/issues/81

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Detecting xruns in process callback","articleBody":"Hi and thanks for the great library, been using it for years!\r\n\r\n**What's the best way to detect if the last process callback lead to an xrun?** Here's my use case: I'm sending MIDI, which works 99% of the time. But when an xrun occurs, the MIDI events aren't sent to connected inputs and on the next process callback I clear the buffer and they're lost forever. Here's how I'm currently doing it:\r\n\r\n```python\r\njack_midi_event_write = jack._lib.jack_midi_event_write\r\n\r\njack_port_get_buffer = jack._lib.jack_port_get_buffer\r\n\r\n\r\nclass Process:\r\n    __slots__ = ('_before', '_buffer', '_client', '_port', '_xrun')\r\n\r\n    def __init__(self, client: jack.Client, port: jack.OwnMidiPort) -\u003e None:\r\n        self._before = 0;\r\n        self._buffer = jack.RingBuffer(2 ** 8)\r\n        self._xrun = threading.Event()\r\n        self._client = client\r\n        self._port = port\r\n\r\n    def process(self, frames: int) -\u003e None:\r\n        xrun = self._xrun\r\n        xrun_set = xrun.is_set()\r\n        port = self._port\r\n        client = port._client\r\n        last_frame_time = client.last_frame_time\r\n        blocksize = client.blocksize\r\n\r\n        if not xrun_set and last_frame_time - blocksize == self._before:\r\n            port.clear_buffer()\r\n        if xrun_set:\r\n            xrun.clear()\r\n\r\n        self._before = last_frame_time\r\n        src_buffer = self._buffer\r\n        space = src_buffer.read_space\r\n\r\n        if space != 0:\r\n            data = src_buffer.read(space)\r\n            dst_buffer = jack_port_get_buffer(port._ptr, blocksize)\r\n            i = 0\r\n            while i != space:\r\n                jack_midi_event_write(dst_buffer, 0, data[i : i + 3], 3)\r\n                i += 3\r\n\r\n    def handle_xrun(self, delay_usec: float) -\u003e None:\r\n        self._xrun.set()\r\n\r\n    def _append(self, event: Tuple[int, int, int]) -\u003e None:\r\n        self._buffer.write(bytes(event))\r\n\r\n    def note_on(self, note: int) -\u003e None:\r\n        self._append((0x99, note, 100))\r\n\r\n    def note_off(self, note: int) -\u003e None:\r\n        self._append((0x89, note, 0))\r\n```\r\nI'm doing two things:\r\n\r\n1. I'm comparing `last_frame_time - blocksize` to the `last_frame_time` on the previous process callback.\r\n\r\n2. Using the `set_xrun_callback` to set a `threading.Event()`\r\n\r\nI'm not sure if I'm doing any of this correctly, just experimenting to see what works. I know you're not meant to use Python for realtime, but it's working too well to justify moving to C++.\r\n\r\nThanks.\r\n","author":{"url":"https://github.com/dj-foxxy","@type":"Person","name":"dj-foxxy"},"datePublished":"2020-01-23T11:09:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/81/jackclient-python/issues/81"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:18b807be-a396-63c2-359e-955ef064a428
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idED56:3461FF:EAA2DA:132024F:6976D229
html-safe-nonce53190cffc3b1ae15744cab52493694f14439ec8dda4424321fc96d85b3b34d31
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDU2OjM0NjFGRjpFQUEyREE6MTMyMDI0Rjo2OTc2RDIyOSIsInZpc2l0b3JfaWQiOiIxODIwNTY2OTgyNzY0MTg4MjAxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac7d89b989637bf578a290c852d4cc81c1de657300e8bbac7d12f81899fafc16dd
hovercard-subject-tagissue:554090030
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/spatialaudio/jackclient-python/81/issue_layout
twitter:imagehttps://opengraph.githubassets.com/004f5b9d24b50f3cab74ba60e6bbd468cd928e5043a30fc53a743d58567631ac/spatialaudio/jackclient-python/issues/81
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/004f5b9d24b50f3cab74ba60e6bbd468cd928e5043a30fc53a743d58567631ac/spatialaudio/jackclient-python/issues/81
og:image:altHi and thanks for the great library, been using it for years! What's the best way to detect if the last process callback lead to an xrun? Here's my use case: I'm sending MIDI, which works 99% of th...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedj-foxxy
hostnamegithub.com
expected-hostnamegithub.com
None01d198479908d09a841b2febe8eb105a81af2af7d81830960fe0971e1f4adc09
turbo-cache-controlno-preview
go-importgithub.com/spatialaudio/jackclient-python git https://github.com/spatialaudio/jackclient-python.git
octolytics-dimension-user_id7491513
octolytics-dimension-user_loginspatialaudio
octolytics-dimension-repository_id27613463
octolytics-dimension-repository_nwospatialaudio/jackclient-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27613463
octolytics-dimension-repository_network_root_nwospatialaudio/jackclient-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef752335dbbea672610081196a1998e39aec5e14b
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/issues/81#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fspatialaudio%2Fjackclient-python%2Fissues%2F81
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fspatialaudio%2Fjackclient-python%2Fissues%2F81
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=spatialaudio%2Fjackclient-python
Reloadhttps://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/issues/81
Reloadhttps://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/issues/81
Reloadhttps://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/issues/81
spatialaudio https://patch-diff.githubusercontent.com/spatialaudio
jackclient-pythonhttps://patch-diff.githubusercontent.com/spatialaudio/jackclient-python
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fspatialaudio%2Fjackclient-python
Fork 28 https://patch-diff.githubusercontent.com/login?return_to=%2Fspatialaudio%2Fjackclient-python
Star 149 https://patch-diff.githubusercontent.com/login?return_to=%2Fspatialaudio%2Fjackclient-python
Code https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python
Issues 14 https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/issues
Pull requests 2 https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/pulls
Actions https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/actions
Wiki https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/wiki
Security 0 https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/security
Insights https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/pulse
Code https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python
Issues https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/issues
Pull requests https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/pulls
Actions https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/actions
Wiki https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/wiki
Security https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/security
Insights https://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/spatialaudio/jackclient-python/issues/81
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/spatialaudio/jackclient-python/issues/81
Detecting xruns in process callbackhttps://patch-diff.githubusercontent.com/spatialaudio/jackclient-python/issues/81#top
questionhttps://github.com/spatialaudio/jackclient-python/issues?q=state%3Aopen%20label%3A%22question%22
https://github.com/dj-foxxy
https://github.com/dj-foxxy
dj-foxxyhttps://github.com/dj-foxxy
on Jan 23, 2020https://github.com/spatialaudio/jackclient-python/issues/81#issue-554090030
questionhttps://github.com/spatialaudio/jackclient-python/issues?q=state%3Aopen%20label%3A%22question%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.