Matlab Scripts on C-Chord

Matlab Scripts on C-Chord

In my note on Intervals of Notes, I said I would provide a Matlab script that I wrote to compare notes and build versions of the C-chord. My Word version of the document had tables of icons that played short sound samples. Maybe someone can tell me how to incorporate something like that in LinkedIn. Anyway, here is the script that I used to build the files. This is basically how I write scripts or programs or code. Being an old dude, I learned Fortran, then Fortran 77. I caught the tail end of cards. I have written in those and C and C++. It's all the same, you just have to learn the particular syntax. I also am very good at scavenging from bits and pieces of code either I wrote before, or someone else wrote and posted. It is "fun" trying to figure out what someone else was trying to do. Anyway, if you want to, and if you happen to have Matlab on your computer, you can play around with this bit of script. If you don't like whatever syntax I am using, oh well, modify it. Make it work for you.

Inton = 2; % Inton:? 1 = Just Intonation (JI), 2 = Equal Temperament (ET)

?

A1 = 1.0; %? Note of C, 261.63 Hz

A2 = 1.0; %? Note of E, 327.04 or 329.63 Hz (JI or ET)

A3 = 1.0; %? Note of G, 392.45 or 392 Hz (JI or ET)

B = 1.0;? %? Attenuation of Higher orders

?

Ffund1(1) = 261.63;? %? Note of C

Ffund1(30) = 0.0;

A(1) = A1;

w(1) = 2*pi*Ffund1(1);

s1 = A(1) sin(w(1) t);

for i = 2:30

??? Ffund1(i) = Ffund1(1) * i;

??? w(i) = 2*pi*Ffund1(i);

??? A(i) = A(i-1) * B;

??? p1(i) = 2*pi*rand;

??? s1 = s1 + A(i) sin(p1(i)+(w(i) t));

end

?

Ffund2(1) = Ffund1(1) * 5/4;? %? Note of E

if Inton == 2

??? Ffund2(1) = Ffund1(1) * 2^(4/12);

end

Ffund2(30) = 0.0;

A(1) = A2;

w(1) = 2*pi*Ffund2(1);

s2 = A(1) sin(w(1) t);

for i = 2:30

??? Ffund2(i) = Ffund2(1) * i;

??? w(i) = 2*pi*Ffund2(i);

??? A(i) = A(i-1) * B;

??? p2(i) = 2*pi*rand;

??? s2 = s2 + A(i) sin(p2(i)+(w(i) t));

end

?

Ffund3(1) = Ffund1(1) * 3/2;? %? Note of G

if Inton == 2

??? Ffund3(1) = Ffund1(1) * 2^(7/12);

end

Ffund3(30) = 0.0;

A(1) = A3;

w(1) = 2*pi*Ffund3(1);

s3 = A(1) sin(w(1) t);

for i = 2:30

??? Ffund3(i) = Ffund3(1) * i;

??? w(i) = 2*pi*Ffund3(i);

??? A(i) = A(i-1) * B;

??? p3(i) = 2*pi*rand;

??? s3 = s3 + A(i) sin(p3(i)+(w(i) t));

end

?

sComposite = s1 + s2 + s3;????????????????????? % Generate composite of tones s and s2

sCompositeNorm = sComposite / max(abs(sComposite));

?

sound(sCompositeNorm, Fs)????????????????????% Produce Composite Tone s + s2 As Sound

?

filename = 'CEG_1p0harms_ET_RandomPhase0.wav';

audiowrite(filename,sCompositeNorm,Fs);

?

要查看或添加评论,请登录

Jeff Girard, PhD的更多文章

  • Bass Re-build

    Bass Re-build

    Like with anything, there is a wide range of prices on bass guitars that, I think, follows name, quality, durability…

  • A Flea Market Jewel

    A Flea Market Jewel

    The previous sections were meant to provide context to the following story. I have played a Fender jazz bass since I…

  • Spirit of the Instrument

    Spirit of the Instrument

    I understand that I am a bit crazy regarding inanimate objects. I show my respects to stones and plants.

    1 条评论
  • Bass Wiring and Electronics

    Bass Wiring and Electronics

    An electric bass has one or two pickups and wiring and electronics that you do not see unless there is a problem. The…

  • 4 or 5 Strings (basses)

    4 or 5 Strings (basses)

    Guitars come with various numbers of strings, as seen in the figure. This may be by design or breakage.

  • Setup or Calibration of the Instrument

    Setup or Calibration of the Instrument

    Calibration is an important aspect of design, analysis, sensing, and use of a (electromagnetic and structurally)…

  • Fingerboard (to Fret or not to Fret)

    Fingerboard (to Fret or not to Fret)

    The fingerboard is a piece of hardwood laminated over the structure of the stiff neck of the guitar. For the bass, the…

  • Intervals of Notes

    Intervals of Notes

    The guitar is an amazing instrument due to its simplicity. A few basic shapes can be used to build the chords of a…

  • Pickups (as opposed to Hookups)

    Pickups (as opposed to Hookups)

    A pickup is an electromagnetic sensor that picks up the motion of the string. At the core is a magnet, and there are…

    1 条评论
  • 3. Excitation and Response

    3. Excitation and Response

    As with other dynamic systems, there is an excitation and a response. Basically, initial conditions are set to a string…

社区洞察

其他会员也浏览了