Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Sound generation in Matlab

Status
Not open for further replies.

matt.marius

Newbie level 1
Joined
May 27, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
9
Hello,
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.

Untitled.png

My code so far:
Code:
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
 

The text you linked to is pretty badly written. As far as I gather, there are a number of tones (12 or 13?) with different frequencies (starting at 100Hz or 148.83Hz?). A time-domain window is applied so the tones are only audible for a finite amount of time... and the fade-in (attack) and fade-out (decay) are configurable by modifying α.

These short (windowed) tones are then used to construct a tone 'pattern', comprising two 'sequences' (one rising, one falling). When the rising sequence reaches the highest tone, it turns around and goes back down (and vice versa for the falling sequence).

Apparently the tones in each sequence proceed along a diatonic scale (which I think is just a standard piano scale). Increasing by one octave means doubling the tone frequency. You can map to the exact notes you want as described here.

So, you can construct the two sequences separately by appending the necessary notes together to form 2 vectors. Then, you should sum the two to get the final pattern. You should only need to construct one period, then play it in a loop as required.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top