Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Matlab
Replies: 11   Last Post: Dec 13, 2012 12:12 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
bartekltg

Posts: 31
Registered: 12/11/12
Re: Matlab
Posted: Dec 12, 2012 10:27 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

W dniu 2012-12-13 03:52, Tanner Handa pisze:
> bartekltg <bartekltg@gmail.com> wrote in message

> so how would I be able to make my happy birthday song sound better to
> make the sounds shorter??
> This is what I have and now when i do t = linspace(0, 0.5, 0.5 *
> freqsamp); it make the frequencies really high pitched.


I don't see difference in tone between

t = linspace(0,1,freqsamp);
a = (sin(1.5*pi*220*t) + sin(1.5*pi*440*t));

and

t2= linspace(0,0.5,freqsamp/2);
a2 = (sin(1.5*pi*220*t2) + sin(1.5*pi*440*t2));


sound(a, freqsamp),sound(a2, freqsamp)



> clear
> freqsamp = 10000;
> t = linspace(0,1,freqsamp);


Add 'note length'

nl = 0.4;

t = linspace(0,nl,nl*freqsamp);


> a = sin(1.5*pi*220*t) + sin(1.5*pi*440*t);
> b = sin(2*pi*220*t) + sin(2*pi*440*t);
> c = sin(2.5*pi*220*t) + sin(2.5*pi*440*t); d = sin(3*pi*220*t) +
> sin(3*pi*440*t); e = sin(4*pi*220*t) + sin(4*pi*440*t);
> f = sin(4.5*pi*220*t) + sin(4.5*pi*440*t);
> g = (sin(5*pi*220*t) + sin(5*pi*440*t))/1.5; h = sin(5.5*pi*220*t) +
> sin(5.5*pi*440*t);
> i = sin(6*pi*220*t) + sin(6*pi*440*t);
> j = sin(6.5*pi*220*t) + sin(6.5*pi*440*t);


OK, I think.
But you can create function to do this:

a= foo (t, 1.5);
b= foo (t, 2) ;
...
g= foo(t,5)/1.5;
...


> sound(a, freqsamp) %HA %3
> sound(a, freqsamp) %ppy %3


And there is very long pause between sounds.
You want to play whole song.

sound ( [a,a,b,a,f,e,a,a,b,a,g,f], freqsamp );

But now you haven't any pause. Create short 'pause'
(vector of silent;) I mean zeros) and add between every note.
Better: add this to function foo.


bartekltg





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.