Reputation: 3336
I'm creating individual notes from a single note thats read in using the wavread
function.
I'm using the resample
function to create these notes. eg:
f5 = resample(a,440,698); %creates note.
f5_short = f5(dur:Hz); %creates duration of note (ie 1 sec)
f5_hf = f5_short(dur:Hz/2); %creates note of half duration
The above code seems to work well. Unfortunately i'm having trouble creating a "double note"... I don't want to just play the same note twice and i've tried the following:
f5_db = f5_short(dur*2:Hz); %exceeds size of matrix
f5_db = f5_short(dur:Hz*2); %exceeds size of matrix
f5_db = resample(f5_short,Hz*2,330); %tried upSampling it and although lengths it, note becomes deeper.
Whats the easiest why to double the length of a not/wav without changing the note? (stretch but maintain the correct note?) Thanks.
Upvotes: 1
Views: 132
Reputation: 19870
You need to double the size of f5_short
, not to index it:
f5_db = repmat(f5_short, 2, 1);
or just
f5_db = [f5_short; f5_short];
If you have pause in the beginning and in the end of f5_short
, but the middle sequence is constant, you can reproduce the middle to get double note. Something like this:
f5_short_len = length(f5_short);
f5_short_mid = floor(f5_short_len/2);
f5_db = [f5_short(1:f5_short_mid,:); ...
repmat(f5_short(f5_short_mid,:),f5_short_len,1); ...
f5_short(f5_short_mid+1:f5_short_len,:)];
If you want to remove the pauses;
f5_short = repmat(f5_short(f5_short_mid),f5_short_len,1);
f5_db = repmat(f5_short, 2, 1);
Upvotes: 2