0
$\begingroup$

I'm trying to generate sounds as described in a scientific paper that I found on the Internet. What I need to do is to generate simple tones in a certain pattern, however I have some issues understanding how to do this correctly. The attached image contains the full description of the method. I'm stuck at "Thirteen tones of this sound .." .I'm confused about how this thirteen tones are selected and how to arrange them correctly. If anyone could provide some help, it would be much appreciated.

enter image description here

My code so far:

function testaudio()

sampleRate = 44100;
duration  = 0.5;
freqs = [100 200 300 400 500 600 700 800 900 1000 1100 1200];

[signal t] = generateTone(freqs, sampleRate, duration);
sound(signal, sampleRate);

%generates a tone (pure or complex)
function [y t] = generateTone(freqs, sampleRate, duration)
    timeSamples = duration * sampleRate;

    t = linspace(0, duration, timeSamples);
    y = zeros(size(t));
    env = generateEnvelope(t);

    for i=1:length(freqs)
        temp = env.*sin(2*pi*freqs(i)*t);
        y = y + temp;
    end


    % amplitude normalisation
    y = y' / max(abs(y));

end

function y = generateEnvelope(t, alfa)
    alfa = 1;
    y = (-t.^alfa) .* log(t./max(t));
    y(1) = 0;
end

end
$\endgroup$
  • $\begingroup$ why is alfa an argument to generateEnvelope( ) when you just set it to 1? and why bother to use env separately int the loop with sin(2*pifreqs(i)*t)*, since it is not a function of i? you could just as well add up the sinusoids and multiply the sum with env. $\endgroup$ – robert bristow-johnson May 28 '14 at 0:54
  • $\begingroup$ also, in your call to generateEnvelope( ), the number of arguments is 1, but the function definition has 2 arguments. $\endgroup$ – robert bristow-johnson May 28 '14 at 1:41
1
$\begingroup$

The section on 12 added sidetones is referring to something different to the section on thirteen notes.

In regards to 13 notes: By diatonic I think the mean a diatonic musical scale, with the lowest note at 148.83Hz.

From this site: http://www.phy.mtu.edu/~suits/notefreq446.html 148.83Hz is note $D_3$

So I would choose 13 consecutive notes in the D-scale starting with $D_3$. The notes are played according to Figure 1. Each note lasts 8.40s/72 = 7/60 s.

However the notes look equally spaced in frequency in Figure 1. So I think they might mean a chromatic scale with equal temperament. That would make more sense as the 13th note would be one octave above the first note, and each note would be $^{12}\sqrt{2}$ apart. Code then:

low_note = 148.83;
notes = low_note .* nthroot(2,12).^(0:1:12);

signal = [];

% First section
for k = 1:12
    signal = [signal, generateTone(notes(13-k+1), 44100, 7/60); % High note
    signal = [signal, generateTone(notes(k), 44100, 7/60); % Low note
end
% Second section
for k = 13:-1:2    % Reverse
    signal = [signal, generateTone(notes(13-k+1), 44100, 7/60); % High note
    signal = [signal, generateTone(notes(k), 44100, 7/60); % Low note
end
% Third section
for k = 1:12
    signal = [signal, generateTone(notes(13-k+1), 44100, 7/60); % High note
    signal = [signal, generateTone(notes(k), 44100, 7/60); % Low note
end
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.