MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

MATLAB to Mathematica Program Conversion Needed


  • To: mathgroup@smc.vnet.net
  • Subject: [mg12260] MATLAB to Mathematica Program Conversion Needed
  • From: "Benjamin Tubb" <brtubb@cybertron.com>
  • Date: Tue, 5 May 1998 03:29:56 -0400
  • Organization: All USENET -- http://www.Supernews.com

Anyone who has the "luxury" of having MATLAB and Mathematica who can
convert the following MATLAB code for Mathematica, please do so. It
would be greatly appreciated. It is from the book "Tuning, Timbre,
Spectrum, and Scale" by William A. Sethares (1998).

MATLAB code version:
--------------------
%
% Additive Synthesis
%
% sr = sampling rate
% time = duration of wave to generate (seconds) % freq = frequencies of
partials
% amp = amplitudes of partials
% decay = decay rate of partials, (big=fast  small=slow) % filename =
saves to this filename, use filename.aif for %             mac and
filename.wav for PC %
sr=44100; time=2; freq=[100 200 300 400 500]; amp=[1 1 1 1 1];
decay=.003*ones(size(freq)); filename = 'yoursound.aif';

pi2=2*pi; t=pi2:pi2/sr:pi2*(1+time); wave=0*ones(size(t));
for i=1:length(freq)
  env=exp(-abs(decay(i)*rand/time)*[1:length(wave)]);
  wave=wave+amp(i)*env.*cos(freq(i)*t+pi2*rand); end
writesound(wave,sr,filename)
--------------------

Thanks in advance for any help.

----------------
Benjamin Tubb
brtubb@cybertron.com
http://home.cybertron.com/~brtubb





  • Prev by Date: a^n*b^n != (a*b)^n
  • Next by Date: Formating output for email
  • Prev by thread: Re: a^n*b^n != (a*b)^n
  • Next by thread: Re: MATLAB to Mathematica Program Conversion Needed