Skip to content

Commit

Permalink
Merge pull request #22 from cinelexi/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
4lm committed Sep 21, 2019
2 parents 75e9501 + 254ddfa commit 7c05517
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Dev branch: [![Build Status](https://travis-ci.com/cinelexi/itu-r-468-weighting.

## Introduction

This project consists of a sole function named `r468`. The function takes a frequency value and returns a weighted gain value. For weightening, the [ITU-R BS.468-4](https://www.itu.int/rec/R-REC-BS.468-4-198607-I/en) standard and the [SMPTE RP 2054:2010](https://ieeexplore.ieee.org/document/7290513) recommended practice are followed.
This project consists of a sole function named `r468()`. The function takes a frequency value and returns a weighted gain value. For weightening, the [ITU-R BS.468-4](https://www.itu.int/rec/R-REC-BS.468-4-198607-I/en) standard and the [SMPTE RP 2054:2010](https://ieeexplore.ieee.org/document/7290513) recommended practice are followed.

The math for this project is taken from Wikipedia (as of 2019-08-08):

Expand All @@ -27,7 +27,7 @@ The math for this project is taken from Wikipedia (as of 2019-08-08):
pip install itu-r-468-weighting
```

More infos on the [project page](https://pypi.org/project/itu-r-468-weighting/) at PyPI.
More infos on the project page at [PyPI](https://pypi.org/project/itu-r-468-weighting/).

## Example Usage

Expand Down
16 changes: 7 additions & 9 deletions itu_r_468_weighting/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,12 @@ def r468(frequency_hz: Union[int, float], khz_option: str, returns: str) -> floa
else:
raise ValueError

f1, f2, f3, f4, f5, f6 = (
frequency_hz,
frequency_hz ** 2,
frequency_hz ** 3,
frequency_hz ** 4,
frequency_hz ** 5,
frequency_hz ** 6,
)
f1 = frequency_hz
f2 = f1 * f1
f3 = f1 * f2
f4 = f2 * f2
f5 = f1 * f4
f6 = f3 * f3
h1 = (
(-4.7373389813783836e-24 * f6)
+ (2.0438283336061252e-15 * f4)
Expand All @@ -68,7 +66,7 @@ def r468(frequency_hz: Union[int, float], khz_option: str, returns: str) -> floa
- (2.1181508875186556e-11 * f3)
+ (0.0005559488023498643 * f1)
)
r_itu = (0.0001246332637532143 * f1) / sqrt(h1 ** 2 + h2 ** 2)
r_itu = (0.0001246332637532143 * f1) / sqrt(h1 * h1 + h2 * h2)

if returns == "db":
if khz_option == "1khz":
Expand Down

0 comments on commit 7c05517

Please sign in to comment.