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

Some functions added #19

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

migperfer
Copy link

@migperfer migperfer commented Jan 25, 2020

Reference Issue

No reference issue

What does this implement/fix? Explain your changes.

Implement a function that were not wrapped:
frequency multiply: To multiply all frequencies by a certain factor, helpful with some stuff that shifting by semitones cannot achieve. Is the -f option in the CLI

tempo shift: Instead of calculating manually the ratio conversion for the tempo, use the function already included in rubberband

@migperfer migperfer changed the title Some more functions Frequency multiply Jan 25, 2020
@migperfer migperfer changed the title Frequency multiply Some functions added Jan 25, 2020
@bmcfee
Copy link
Owner

bmcfee commented Jan 27, 2020

Thanks for doing this! It appears that the CI build is (mostly) failing due to changes in the pytest API since I last worked on this package. We should address those in a separate PR, but in the meantime I'll leave some comments on this one.

@bmcfee
Copy link
Owner

bmcfee commented Jan 27, 2020

Quick update: I've fixed the pytest issues, so if you could rebase to the current master, the travis build should work again.

return __rubberband(y, sr, **rbargs)


def change_tempo(y, sr, X, Y, rbargs=None):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this different from time_stretch?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not, it just saves the step of creating the coefficient between the two tempos.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, i get it now. Thanks. LGTM


def change_tempo(y, sr, X, Y, rbargs=None):
'''Multiply the frequencies inside an audio time series.
The equivalent of the -f option.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-f option? are you sure?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh, my bad, problems of doing copy-paste. Thanks for noticing it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. It happens

Copy link

@lostanlen lostanlen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Added functions were not in global import
Copy link
Owner

@bmcfee bmcfee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... how embarrassing. I wrote a bunch of comments on this PR several months ago, but forgot to click "submit" on the review! Apologies.

Sampling rate of `y`

X : float
Shift magnitudes in spectrum by X
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this parameter have a more descriptive name? X doesn't convey much here, maybe factor or shift would be more appropriate.

The description of this parameter (and the function docstring itself) is also a bit confusing. I assume this means that energy at frequency f maps to frequency f*factor? I think it would be best to be explicit about what the exact calculation is.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, factor seems a better name.

The rubberband-cli documentation just says Change frequency by multiple X. I was looking in the rubberband repository, and I guess by this line that this does f*factor. I think we could safely describe this parameter as you said.


def change_tempo(y, sr, X, Y, rbargs=None):
'''Multiply the frequencies inside an audio time series.
The equivalent of the -f option.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem accurate; copypasta?

Again, X and Y are not descriptive variable names, and particularly confusing given that there's already a lower-case y parameter.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! It was a copypasta and I committed the changes already. I guess original_tempo and final_tempo are better names than X and Y.


rbargs.setdefault('--tempo', '%s:%s' % (X, Y))

return __rubberband(y, sr, **rbargs)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add unit tests for this new functionality?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me take a look at how do they work! For change_tempo and frequency_shift, right?

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

Successfully merging this pull request may close these issues.

3 participants