Like I mentioned, I came across Newton's law of cooling, which is a 1st order ODE, and plugged it into MATLAB with the intent of finding our just how long it takes my ice cube to melt in my green tea. The plot of the solution somehow sparked my memory of the old notion of using ODE's for music effects. Today I came up with the following scheme:
Use Newton's law of cooling to create a 1-D vector with the index being time. Each element of the vector will contain the frequency of a tone generated from a sinusoid at time given by its index. The solution to the law of cooling is an exponential curve that eventually settles on a constant value as time goes to infinity (much like a charging capacitor).
For a test run, I chose this value to be 440Hz. I then made a MATLAB function which creates a wave file which consists of a sine wave whose frequency depends on the solution to Newton's law of cooling. I had to fool around with different sample rates but I got the gist of how it sounds and was able to refresh some forgotten MATLAB skills. I then looked at the wave file in Cool Edit and did a spectrum analysis and listened to the signal at different sample rates.
Here is a function to show what I made today:
%Brian Tice
%November 3rd, 2009
%Fullerton, CA
function icemelt(t)
%
% ICEMELT 0.1:
% Use newton's law of cooling to create a .wav file
%
% t: length of wave file in seconds.
fs=44100; %sample freq in Hz
if (nargin == 0)
t = [0:1/fs:.2];
elseif (nargin == 1)
t = [0:1/fs:t];
end
freq = (80 - 440)*exp(-0.8*t)+440; %calculate the frequency based on
%sol'n to Newton's law of cooling
%where temperature maps to
%frequency of the sinusoid
wave = sin(2*pi*(freq.*t)); %create wave with frequency calculated
%from equation above.
plot(freq)
sound(wave,fs);
wavwrite(wave,44100,'icemelt.wav');
So what lies left to be done?
For a test run, I chose this value to be 440Hz. I then made a MATLAB function which creates a wave file which consists of a sine wave whose frequency depends on the solution to Newton's law of cooling. I had to fool around with different sample rates but I got the gist of how it sounds and was able to refresh some forgotten MATLAB skills. I then looked at the wave file in Cool Edit and did a spectrum analysis and listened to the signal at different sample rates.
Here is a function to show what I made today:
%Brian Tice
%November 3rd, 2009
%Fullerton, CA
function icemelt(t)
%
% ICEMELT 0.1:
% Use newton's law of cooling to create a .wav file
%
% t: length of wave file in seconds.
fs=44100; %sample freq in Hz
if (nargin == 0)
t = [0:1/fs:.2];
elseif (nargin == 1)
t = [0:1/fs:t];
end
freq = (80 - 440)*exp(-0.8*t)+440; %calculate the frequency based on
%sol'n to Newton's law of cooling
%where temperature maps to
%frequency of the sinusoid
wave = sin(2*pi*(freq.*t)); %create wave with frequency calculated
%from equation above.
plot(freq)
sound(wave,fs);
wavwrite(wave,44100,'icemelt.wav');
So what lies left to be done?
1.) Figure out how I can feed a guitar signal into something like this model. Right now I am dealing only with simple computer generated sinusoids.
2.) Try out different equations to try and make something that sounds really cool.
3.) Build an app that makes this easy and fun to manipulate.
4.) Get deeper into the DSP it would take to turn this idea into hardware.
No comments:
Post a Comment