Skip to content

sync flanger period to tempo#1257

Merged
daschuer merged 10 commits intomixxxdj:masterfrom
Be-ing:tempo_sync_flanger
Oct 8, 2017
Merged

sync flanger period to tempo#1257
daschuer merged 10 commits intomixxxdj:masterfrom
Be-ing:tempo_sync_flanger

Conversation

@Be-ing
Copy link
Copy Markdown
Contributor

@Be-ing Be-ing commented May 10, 2017

plus remove unused delay parameter and remove assumption of 44.1 kHz
sample rate

Depends on:

Copy link
Copy Markdown
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

Could you explain why we do not need the delay knob?
What happens with channels without a beat value like Aux?

Comment thread src/effects/native/flangereffect.cpp Outdated
const unsigned int kMaxDelay = 5000;
const unsigned int kLfoAmplitude = 240;
const unsigned int kAverageDelayLength = 250;
const unsigned int kMaxDelay = 441000000;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the unit of these values? What does they mean? A comment could be useful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought they were previously all in units of samples, but I could be wrong. @JosepMaJAZ or @rryan could you clarify?

Comment thread src/effects/native/flangereffect.cpp Outdated
const int kChannels = 2;

const unsigned int lfoAmplitude =
kLfoAmplitude / sampleRate / kChannels;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is the Amplitudes sampleRate depending?

@Be-ing
Copy link
Copy Markdown
Contributor Author

Be-ing commented May 10, 2017

Could you explain why we do not need the delay knob?

Well it wasn't doing anything before. Do you have ideas for where in the code it could manipulate something in a musically useful way?

What happens with channels without a beat value like Aux?

It acts like the tempo is 100 BPM because I don't know what else to do.

@JosepMaJAZ
Copy link
Copy Markdown
Contributor

Mmm.. a flanger effect is such that it mixes the input signal into output with a delay that oscillates slowly over a center delay value. The delay parameter would generally mean this center value, and there are also the commonly known parameters of amplitude of the LFO and for the speed of that LFO.

They can also have a stereo phase, which means that the phase of the left audio channel and the right audio channel would not be at the same phase, which does a sort of ping-pong effect as well as image widening, and could also have feedback.

And in the case where the speed parameter is removed, on other applications i tended to like the effect of a 0.25Hz LFO.

Comment thread src/effects/native/flangereffect.cpp Outdated

CSAMPLE periodFraction = CSAMPLE(pState->time) / lfoPeriod;
CSAMPLE delay = kAverageDelayLength + kLfoAmplitude * sin(M_PI * 2.0f * periodFraction);
CSAMPLE delay = averageDelayLength + lfoAmplitude * sin(M_PI * 2.0f * periodFraction);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@JosepMaJAZ I tried turning the center value (averageDelayLength) and amplitude into effect parameters but it didn't seem very useful to me. Maybe I just didn't choose appropriate scales for them. Do you have suggestions?

@Be-ing Be-ing force-pushed the tempo_sync_flanger branch from 41e590a to c1ee02a Compare May 14, 2017 16:44
plus remove unused delay parameter and remove assumption of 44.1 kHz
sample rate
@Be-ing Be-ing force-pushed the tempo_sync_flanger branch from c1ee02a to 7bd4876 Compare May 14, 2017 17:16
@Be-ing
Copy link
Copy Markdown
Contributor Author

Be-ing commented May 14, 2017

It was only the period that needed to be adjusted for the sample rate. Now it sounds the same when changing the sample rate (which is not the case in master).

Comment thread src/effects/native/flangereffect.cpp Outdated
CSAMPLE lfoPeriod;
if (m_pSyncParameter->toBool() && groupFeatures.has_beat_length) {
// period is a number of beats
lfoPeriod = periodTime * groupFeatures.beat_length;
Copy link
Copy Markdown
Contributor Author

@Be-ing Be-ing May 15, 2017

Choose a reason for hiding this comment

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

This assumes that the engine's current sample rate is the same as the file's sample rate. The GroupFeatureState does not have any information about the file's sample rate. I will fix that after this, #1256, and #1261 are merged to avoid merge conflicts.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do you need the file sample rate here? I think the track is already re-sampled here.

Copy link
Copy Markdown
Contributor Author

@Be-ing Be-ing May 15, 2017

Choose a reason for hiding this comment

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

The input signal is resampled, but groupFeatures.beat_length is calculated from the beat_prev and beat_next ControlObjects in BpmControl::collectFeatures, which does not seem to be adjusted for the engine sample rate. When I play a 44.1 kHz track at 44.1 kHz with a tempo synced effect it works as expected, but when I set Mixxx's sample rate to 96 kHz, the period approximately halves.

@radusuciu
Copy link
Copy Markdown
Contributor

What happens with channels without a beat value like Aux?

It acts like the tempo is 100 BPM because I don't know what else to do.

Perhaps there could be a way to tap in a tempo? The delay knob isn't so good by itself, but if you could tap it in (clicking on delay knob repeatedly or separate button), you could use it to make fine adjustments.

@Be-ing
Copy link
Copy Markdown
Contributor Author

Be-ing commented Jun 20, 2017

That's a good idea, but I think it is beyond the scope of this simple pull request.

@radusuciu
Copy link
Copy Markdown
Contributor

Agreed, just pointing out that there could be a reason to keep the delay knob/parameter in the meantime.

@Be-ing
Copy link
Copy Markdown
Contributor Author

Be-ing commented Jun 20, 2017

The delay knob was removed because it literally did nothing. I think you are confusing it with the period parameter.

@Be-ing
Copy link
Copy Markdown
Contributor Author

Be-ing commented Jul 4, 2017

This effect is difficult to hear without the Depth parameter way up, but then it makes the the output quite a bit louder than the input. Any ideas to improve that?

@Be-ing Be-ing mentioned this pull request Jul 4, 2017
1 task
@Be-ing
Copy link
Copy Markdown
Contributor Author

Be-ing commented Sep 26, 2017

I have added a Triplet parameter like Echo. Like Phaser and unlike Echo, I do not think there is a use case for a Quantize parameter.

@Be-ing
Copy link
Copy Markdown
Contributor Author

Be-ing commented Sep 27, 2017

Anyone care to test? @radusuciu, @MK-42?

@MK-42
Copy link
Copy Markdown
Contributor

MK-42 commented Oct 2, 2017

Sorry, I'm not actively using the effects and only have little experience with "how that should hear like", so I'm probably the wrong one for this PR

Comment thread src/effects/native/flangereffect.cpp Outdated
period->setUnitsHint(EffectManifestParameter::UnitsHint::BEATS);
period->setMinimum(0.00);
period->setMaximum(4.00);
period->setDefault(0.50);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I prefer here 2. That sounds good and is the centre position.
1 works also for me. (currently there is a by two bug that makes 0.50 to 1)

Comment thread src/effects/native/flangereffect.cpp Outdated
lfoPeriod = lfoPeriod * groupFeatures.beat_length_sec
* sampleRate * kChannels;
} else {
// lfoPeriod is a number of seconds
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these comments are confusing, because lfoPeriod variable changes unit. We should use two variables for it.
periodParameter and periodFrames

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What means lfo by the way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, two variables could make the code easier to understand.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Low Frequency Oscillator

Comment thread src/effects/native/flangereffect.cpp Outdated
* sampleRate * kChannels;
} else {
// lfoPeriod is a number of seconds
lfoPeriod = std::max(lfoPeriod, 1/4.0) * sampleRate * kChannels;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

without kChannels, because the loop below is already in stereo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, I will fix this.

Comment thread src/effects/native/flangereffect.cpp Outdated
lfoPeriod /= 3.0;
}
lfoPeriod = lfoPeriod * groupFeatures.beat_length_sec
* sampleRate * kChannels;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

without kChannels, because the loop below is already in stereo.

@daschuer
Copy link
Copy Markdown
Member

daschuer commented Oct 3, 2017

According to:
https://www.premierguitar.com/articles/Get_More_Out_of_Your_Flanger
our depth parameter is wrong. It is currently a "Dry/Wet" parameter sometimes labelled "Mix" on some Stomp boxes.
The original lfoDepth parameter or Width should effect LfoAmplitude.

It would be also Cool to have an Manual Switch to tweak a constant delay.
I am also curious how the "Regen" feedback loop sounds.

A short fix for this PR could be to rename the Depth parameter, though.

@daschuer
Copy link
Copy Markdown
Member

daschuer commented Oct 3, 2017

Ah, I got it, "Manual" sets kAverageDelayLength.
In case Depth is 0, you can sweep the delay manually.

@Be-ing
Copy link
Copy Markdown
Contributor Author

Be-ing commented Oct 5, 2017

Let's keep this PR focused on syncing the period parameter to the tempo and move discussion about the Depth parameter to #1326.

@Be-ing
Copy link
Copy Markdown
Contributor Author

Be-ing commented Oct 8, 2017

Notes addressed.

@daschuer
Copy link
Copy Markdown
Member

daschuer commented Oct 8, 2017

Thank you. LGTM

@daschuer daschuer merged commit e545d0b into mixxxdj:master Oct 8, 2017
@Be-ing
Copy link
Copy Markdown
Contributor Author

Be-ing commented Oct 8, 2017

I was confused by the doubled period but trusted my misunderstanding of the code more than my ears, so thanks for catching that.

@Be-ing Be-ing deleted the tempo_sync_flanger branch October 8, 2017 21:30
@sohet
Copy link
Copy Markdown
Contributor

sohet commented Oct 14, 2017

Thank you for your elaboration, but previous version of Flanger was far more better, at least for me. New Flanger sounds like phaser rather than flanger. To increment the period (default and max value is too short) make the sound more similar to the previous, but something is still missing.

@Be-ing
Copy link
Copy Markdown
Contributor Author

Be-ing commented Oct 14, 2017

What do you think should be the maximum for the Period parameter? 8 beats? 16 beats? You can try different values by editing this line.

@daschuer
Copy link
Copy Markdown
Member

The flanger can be considered as broken.
The depth parameter is actually a mix parameter. I am planning to update it like explained here:
https://www.premierguitar.com/articles/Get_More_Out_of_Your_Flanger
Will that meet you expectations?

@daschuer
Copy link
Copy Markdown
Member

Here it is:
#1362

@Be-ing Be-ing mentioned this pull request Oct 17, 2017
@mixxxbot mixxxbot mentioned this pull request Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants