Skip to content

Commit

Permalink
Merge branch 'internal-FM-LFO'
Browse files Browse the repository at this point in the history
  • Loading branch information
timchurches committed Oct 25, 2015
2 parents b8f290e + f18c1ae commit 1277579
Show file tree
Hide file tree
Showing 8 changed files with 870 additions and 73 deletions.
35 changes: 18 additions & 17 deletions peaks/drums/high_hat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ void HighHat::Init() {
noise_.set_resonance(24000);
noise_.set_mode(SVF_MODE_BP);

vca_coloration_.Init();
vca_coloration_.set_frequency(110 << 7); // 13kHz
vca_coloration_.set_resonance(0);
vca_coloration_.set_mode(SVF_MODE_HP);
// vca_coloration_.Init();
// vca_coloration_.set_frequency(110 << 7); // 13kHz
// vca_coloration_.set_resonance(0);
// vca_coloration_.set_mode(SVF_MODE_HP);

vca_envelope_.Init();
vca_envelope_.set_delay(0);
Expand Down Expand Up @@ -87,29 +87,29 @@ int16_t HighHat::ProcessSingleSample(uint8_t control) {
set_frequency(randomised_frequency) ;
last_frequency_ = randomised_frequency ;

// colour
// decay
random_value = stmlib::Random::GetWord() ;
freq_up = (random_value > 2147483647) ? true : false ;
randomised_frequency = freq_up ?
(last_colour_ + (colour_randomness_ >> 2)) :
(last_colour_ - (colour_randomness_ >> 2));
(last_decay_ + (decay_randomness_ >> 2)) :
(last_decay_ - (decay_randomness_ >> 2));
// Check if we haven't walked out-of-bounds, and if so, reverse direction on last step
if (randomised_frequency < 0 || randomised_frequency > 65535) {
// flip the direction
freq_up = !freq_up ;
randomised_frequency = freq_up ?
(last_colour_ + (colour_randomness_ >> 2)) :
(last_colour_ - (colour_randomness_ >> 2));
(last_decay_ + (decay_randomness_ >> 2)) :
(last_decay_ - (decay_randomness_ >> 2));
}
// constrain randomised frequency - probably not necessary
if (randomised_frequency < 0) {
randomised_frequency = 0;
} else if (randomised_frequency > 65535) {
randomised_frequency = 65535;
}
// set new random frequency
set_colour(randomised_frequency) ;
last_colour_ = randomised_frequency ;
// set new random decay
set_decay(randomised_frequency) ;
last_decay_ = randomised_frequency ;

// Hit it!
vca_envelope_.Trigger(32768 * 15);
Expand Down Expand Up @@ -146,13 +146,14 @@ int16_t HighHat::ProcessSingleSample(uint8_t control) {
int32_t envelope = vca_envelope_.Process() >> 4;
int32_t vca_noise = envelope * filtered_noise >> 14;
CLIP(vca_noise);
int32_t hh = 0;
hh += vca_coloration_.Process(vca_noise);
return vca_noise;
// int32_t hh = 0;
// hh += vca_coloration_.Process(vca_noise);
// hh += vca_coloration_.Process(vca_noise);
hh <<= 1;
// hh <<= 1;
// hh <<= 2;
CLIP(hh);
return hh;
// CLIP(hh);
// return hh;
}


Expand Down
31 changes: 15 additions & 16 deletions peaks/drums/high_hat.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,35 @@ class HighHat {
set_frequency(parameter[0]);
base_frequency_ = parameter[0];
last_frequency_ = base_frequency_;
set_colour(parameter[1]);
base_colour_ = parameter[1];
last_colour_ = base_colour_;
set_decay(parameter[1]);
base_decay_ = parameter[1];
last_decay_ = base_decay_;
} else {
set_frequency(parameter[0]);
base_frequency_ = parameter[0];
last_frequency_ = base_frequency_;
set_colour(parameter[1]);
base_colour_ = parameter[1];
last_colour_ = base_colour_;
set_decay(parameter[1]);
base_decay_ = parameter[1];
last_decay_ = base_decay_;
set_frequency_randomness(parameter[2]);
set_colour_randomness(parameter[3]);
set_decay_randomness(parameter[3]);
}
}

void set_frequency(uint16_t frequency) {
noise_.set_frequency((105 << 7) - ((32767 - frequency) >> 6)); // 8kHz
}

void set_colour(uint16_t colour) {
//vca_coloration_.set_frequency((110 << 7) - ((32767 - colour) >> 6)); // 13kHz
vca_coloration_.set_frequency((65535 - (colour >> 1)) >> 2); // 13kHz
void set_decay(uint16_t decay) {
vca_envelope_.set_decay(4065 + (decay >> 11));
}

void set_frequency_randomness(uint16_t frequency_randomness) {
frequency_randomness_ = frequency_randomness;
}

void set_colour_randomness(uint16_t colour_randomness) {
colour_randomness_ = colour_randomness;
void set_decay_randomness(uint16_t decay_randomness) {
decay_randomness_ = decay_randomness;
}

inline void set_open(bool open) {
Expand All @@ -92,19 +91,19 @@ class HighHat {

private:
Svf noise_;
Svf vca_coloration_;
// Svf vca_coloration_;
Excitation vca_envelope_;

uint32_t phase_[6];

uint16_t frequency_randomness_ ;
uint16_t colour_randomness_ ;
uint16_t decay_randomness_ ;
int32_t randomised_hit_ ;

uint16_t base_frequency_ ;
uint16_t last_frequency_ ;
uint16_t base_colour_ ;
uint16_t last_colour_ ;
uint16_t base_decay_ ;
uint16_t last_decay_ ;

bool open_ ;

Expand Down
Loading

0 comments on commit 1277579

Please sign in to comment.