adamrenklint / bap

A toolkit for making beats and composing sequences with Javascript and Web Audio
MIT License
115 stars 6 forks source link

Pitch shift for slots #46

Closed gurs1kh closed 8 years ago

gurs1kh commented 8 years ago

I think it would be a nice feature to implement if you could shift the pitch for an individual slot since I'd like to use the same sound sample for multiple slots, but apply different pitch shifts to each. I would prefer to do this without loading a new sample for each.

gurs1kh commented 8 years ago

on a similar note, pitch shifting for patterns as a whole could be a good idea too for shifting the entire pattern's pitch all at once

adamrenklint commented 8 years ago

Should already have been possible, but didn't work with re-using layers between slots: fixed this in v0.6

var myKit = bap.kit();
var plong = bap.sample('plong.wav');

myKit.slot('Q').layer(plong);

myKit.slot('W').layer(plong);
myKit.slot('W').pitch = 100;

var myPattern = bap.pattern();
myPattern.channel(1).add(
  ['1.odd.01', '1Q', 96],
  ['1.even.01', '1W', 96]
);

I also added that you can do it for a complete pattern:

var myKit = bap.kit();
var plong = bap.sample('plong.wav');

myKit.slot('Q').layer(plong);
myKit.slot('W').layer(plong);

var myPattern = bap.pattern();
myPattern.channel(1).add(
  ['1.odd.01', '1Q', 96],
  ['1.even.01', '1W', 96]
);

myPattern.pitch = 100;
gurs1kh commented 8 years ago

There still seems to be an issue. If I change the overall pitch for the pattern, it works fine (well, for increasing; the decreasing part is being discussed on a different thread). But after increasing the pattern pitch, the slot pitch becomes off. For example, increase the pattern pitch by 1 semitone (about 5.946309435929531) and then increase the slot or sample pitch by 50% and you'll notice that the resulting slot/sample pitch is actually about half a semitone flat of 50%.

adamrenklint commented 8 years ago

I'm gonna hold off investigating this until pitching itself is figured out in https://github.com/adamrenklint/bap/issues/45

adamrenklint commented 8 years ago

This should be solved in v0.7, which includes the change to make pitch based on semitones, and the bap.pitchByRatio helper