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

Fix test signal for 24-bit planar data #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Mediagrains Library Changelog

## 2.14.2
- Fix 24-bit planar audio test signal that should occupy 32-bits.

## 2.14.1
- Fix unbounded timerange in legacy test signal generators.

Expand Down
7 changes: 5 additions & 2 deletions mediagrains/patterngenerators/audio/tone.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ def _get_samples(self, offs: int) -> bytes:
CogAudioFormat.S16_INTERLEAVED]:
formatted_sample_data = [round(x*self.volume*(1 << 15)) for x in self._sample_values]
depth = 16
elif self.cog_audio_format in [CogAudioFormat.S24_PLANES,
CogAudioFormat.S24_PAIRS,
elif self.cog_audio_format in [CogAudioFormat.S24_PAIRS,
CogAudioFormat.S24_INTERLEAVED]:
formatted_sample_data = [round(x*self.volume*(1 << 23)) for x in self._sample_values]
depth = 24
elif self.cog_audio_format in [CogAudioFormat.S24_PLANES]:
# signed 24-bit occupies lower part of unsigned 32-bit
formatted_sample_data = [((round(x*self.volume*(1 << 31))+2**32) >> 8) & 0x00ffffff for x in self._sample_values]
depth = 32
elif self.cog_audio_format in [CogAudioFormat.S32_PLANES,
CogAudioFormat.S32_PAIRS,
CogAudioFormat.S32_INTERLEAVED]:
Expand Down
7 changes: 5 additions & 2 deletions mediagrains/testsignalgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,14 @@ def AudioGrainsLoopingData(src_id, flow_id,
CogAudioFormat.S16_INTERLEAVED]:
formatted_sample_data = [round(x*volume*(1 << 15)) for x in sample_data]
depth = 16
elif cog_audio_format in [CogAudioFormat.S24_PLANES,
CogAudioFormat.S24_PAIRS,
elif cog_audio_format in [CogAudioFormat.S24_PAIRS,
CogAudioFormat.S24_INTERLEAVED]:
formatted_sample_data = [round(x*volume*(1 << 23)) for x in sample_data]
depth = 24
elif cog_audio_format in [CogAudioFormat.S24_PLANES]:
# signed 24-bit occupies lower part of unsigned 32-bit
formatted_sample_data = [((round(x*volume*(1 << 31))+2**32) >> 8) & 0x00ffffff for x in sample_data]
depth = 32
elif cog_audio_format in [CogAudioFormat.S32_PLANES,
CogAudioFormat.S32_PAIRS,
CogAudioFormat.S32_INTERLEAVED]:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
]

setup(name="mediagrains",
version="2.14.1.post1",
version="2.14.2",
python_requires='>=3.6.0',
description="Simple utility for grain-based media",
url='https://github.com/bbc/rd-apmm-python-lib-mediagrains',
Expand Down