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

audioop module - request to add a note #44848

Closed
ncryptor mannequin opened this issue Apr 14, 2007 · 3 comments
Closed

audioop module - request to add a note #44848

ncryptor mannequin opened this issue Apr 14, 2007 · 3 comments
Assignees
Labels
docs Documentation in the Doc dir

Comments

@ncryptor
Copy link
Mannequin

ncryptor mannequin commented Apr 14, 2007

BPO 1700821
Nosy @birkenfeld, @rhettinger

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/birkenfeld'
closed_at = <Date 2008-03-24.09:34:51.841>
created_at = <Date 2007-04-14.23:07:14.000>
labels = ['docs']
title = 'audioop module - request to add a note'
updated_at = <Date 2008-03-24.09:34:51.826>
user = 'https://bugs.python.org/ncryptor'

bugs.python.org fields:

activity = <Date 2008-03-24.09:34:51.826>
actor = 'georg.brandl'
assignee = 'georg.brandl'
closed = True
closed_date = <Date 2008-03-24.09:34:51.841>
closer = 'georg.brandl'
components = ['Documentation']
creation = <Date 2007-04-14.23:07:14.000>
creator = 'ncryptor'
dependencies = []
files = []
hgrepos = []
issue_num = 1700821
keywords = []
message_count = 3.0
messages = ['31788', '31789', '64408']
nosy_count = 3.0
nosy_names = ['georg.brandl', 'rhettinger', 'ncryptor']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1700821'
versions = []

@ncryptor
Copy link
Mannequin Author

ncryptor mannequin commented Apr 14, 2007

The audioop function lin2lin converts sample sizes of linear pcm fragments.
However, when converting to 8-bit, there is a pitfall (that wasted for me a few hours).
In some audio formats, such as .WAV files, 16 and 32 bit samples are signed, but 8 bit samples are unsigned. So when converting from 2 to 1 byte wide samples, you need to also add 128 to the result.
Example code:

new_frames = audioop.lin2lin(frames, old_width, new_width)
if 1 == new_width:
   new_frames = audioop.bias(new_frames, 1, 128)

the same, in reverse, has to be applied when converting from 8 to 16 or 32 bit width samples.

This wasted so much time for me and is hardly documented.

@ncryptor ncryptor mannequin assigned rhettinger Apr 14, 2007
@ncryptor ncryptor mannequin added the docs Documentation in the Doc dir label Apr 14, 2007
@ncryptor ncryptor mannequin assigned rhettinger Apr 14, 2007
@ncryptor ncryptor mannequin added the docs Documentation in the Doc dir label Apr 14, 2007
@rhettinger
Copy link
Contributor

I will add a note.

@rhettinger rhettinger assigned birkenfeld and unassigned rhettinger Mar 23, 2008
@birkenfeld
Copy link
Member

Fixed in r61842.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

2 participants