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

implemented pitch contour sonification #195

Merged
merged 1 commit into from May 27, 2016
Merged

Conversation

bmcfee
Copy link
Collaborator

@bmcfee bmcfee commented May 26, 2016

resolves #194

@bmcfee bmcfee self-assigned this May 26, 2016
@bmcfee
Copy link
Collaborator Author

bmcfee commented May 26, 2016

@craffel @justinsalamon ready for CR I think.


# Clamp the extrapolated values
x[:int(times.min() * fs)] = 0
x[int(times.max() * fs):] = 0
Copy link
Owner

Choose a reason for hiding this comment

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

I see why you did this from the test below, but this must create an actual click, right? Is it really that bad to have a small ramp-down/ramp-up at the beginning and/or end (because that's all your avoiding here, right)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually it's worse than that -- the interpolator seems to be constant-padding instead of using fill_value for extrapolation. Not sure why that is, but it seems incorrect based on my reading of the scipy docs, and it happens in both 0.16.1 and 0.17. This workaround just forces the output to be zero at extrapolation points.

At any rate, the discontinuity here doesn't bother me too much. I can add a ramp if you think it's necessary, but I'd rather keep it simple.

Copy link
Owner

Choose a reason for hiding this comment

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

Actually it's worse than that -- the interpolator seems to be constant-padding instead of using fill_value for extrapolation.

Hmm, seems ok to me:

In [1]: import numpy as np

In [2]: import scipy.interpolate

In [3]: x = np.linspace(.2, 1.1, 10)

In [4]: y = np.random.random_integers(2, 5, 10)

In [5]: f = scipy.interpolate.interp1d(x, y, kind='slinear', fill_value=10., bounds_error=False)

In [6]: f(.15)
Out[6]: array(10.0)

Is that not what you'd expect?

At any rate, the discontinuity here doesn't bother me too much.

Well, not explicitly zeroing out doesn't sound worse, right? Unless there is some nasty behavior I am not seeing, it seems like interpolate will already be zeroing out things.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is that not what you'd expect?

... that is what i'd expect, and i get the same results when i run your code locally. NFC what's going on inside the synthesizer then; i'll investigate.

Well, not explicitly zeroing out doesn't sound worse, right? Unless there is some nasty behavior I am not seeing, it seems like interpolate will already be zeroing out things.

It should be, and it isn't, unless my tests are really broken. I'll report back shortly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Aha! The problem is that testing for zeros at the end of the signal is not correct, since the interpolated frequencies are accumulated through cumsum. This is easily fixable by testing that they're constant though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed. Thanks for catching that.

@craffel
Copy link
Owner

craffel commented May 26, 2016

One minor comment otherwise LGTM.


# Test with an explicit duration
# This forces the interpolator to go off the end of the sampling grid,
# which should put zeros at the end of the signal
Copy link
Owner

Choose a reason for hiding this comment

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

Are these comments still correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If by "signal" we mean "instatnaneous frequencies" then yes; I can clarify though.

stupid pep8

minor efficiency improvements in pitch_contour sonification

fixed the silly test case in pitch_contour sonify

updated test comments in pitch_contour sonification

pep8 is stupid
@craffel
Copy link
Owner

craffel commented May 27, 2016

Merging, thanks for being so quick on this!

@craffel craffel merged commit 5bf7651 into master May 27, 2016
@bmcfee
Copy link
Collaborator Author

bmcfee commented Jun 3, 2016

I think something got screwed up in the git history here? This merge is no longer showing up in the master timeline. The network graph shows the PR still dangling. O_o

@craffel
Copy link
Owner

craffel commented Jun 4, 2016

Weird, I have no idea why that happened. Just re-merged in #198. Looks ok? Github was having some hiccups earlier this week, maybe it has to do with that? I dunno.

@bmcfee
Copy link
Collaborator Author

bmcfee commented Jun 4, 2016

Looks good now, thanks! It's possible that when I ff-pushed to my own fork on the display branch, something got out of sync and/or fat-fingered to upstream (ie craffel/mir_eval). At any rate, all is well now.

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.

continuous pitch sonification
2 participants