Skip to content
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

OpusFile and OpusFileStream: Open Opus files from memory. #90

Open
ijc8 opened this issue Sep 10, 2021 · 4 comments · May be fixed by #91
Open

OpusFile and OpusFileStream: Open Opus files from memory. #90

ijc8 opened this issue Sep 10, 2021 · 4 comments · May be fixed by #91

Comments

@ijc8
Copy link

ijc8 commented Sep 10, 2021

It'd be nice if OpusFile (and, for consistency, OpusFileStream) supported opening Opus files from memory.
The underlying opusfile library supports this via op_open_memory(), and this function is already wrapped in opus.py.

I think this would involve tweaking OpusFile.__init__() and OpusFileStream.__init__() to take path: str OR something like data: memoryview (or maybe collections.abc.ByteString).

(For what it's worth, the opposite direction already works nicely for in-memory usage, as OggOpusWriter accepts memoryview in write() and can take io.BytesIO in __init__().)

Let me know if this seems like a reasonable feature; I'd be happy to submit a PR.

Thanks for the useful bindings!
Ian

@mattgwwalker
Copy link
Collaborator

mattgwwalker commented Sep 11, 2021 via email

@ijc8 ijc8 linked a pull request Sep 11, 2021 that will close this issue
@ijc8
Copy link
Author

ijc8 commented Sep 13, 2021

Hi Matthew,

Great! I went ahead and submitted #91 for this.
A little ctypes finagling was required to avoid an extra copy, but everything typechecks and passes (including the new tests).
Let me know if you'd like to see any changes (in style, API, tests, etc.).

Best,
Ian

@mattgwwalker
Copy link
Collaborator

mattgwwalker commented Sep 14, 2021 via email

@AndreasGocht
Copy link

Hey,

any updates? I accidentally implemented the same functionality 😄

Best,

Andreas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants