Skip to main content
added 78 characters in body
Source Link
roblogic
  • 4.7k
  • 22
  • 25

Chipmunk Basic, 677 303 280 241 228 bytes

dim m(20):d$="GIKNDFGKGIKNDFGK@BDGBDFICGJNEILP":for k=0to 7
for i=0to 4:for o=1to 4:m(o+4*i)=555*2^(asc(mid$(d$,k*4+o))/12+i-8):next:next
for i=1to 17:s(m(i)):next:for i=1to 16:s(m(17-i)):next:next
sub s(x):sound x,.2,50:return

Try the debug version on TutorialsPoint!

The info about chords and octaves in the "music theory" section helped a lot.
Ungolfed:

dim m(20)
d$="GIKNDFGKGIKNDFGK@BDGBDFICGJNEILP"
for k=0to 7                       :' the 8 chords
  for i=0to 4                     :' ascend arpeggio for 5 octaves
    for o=1to 4                   :' broken into 4 notes
      m(o+4*i)=555*2^(asc(mid$(d$,k*4+o))/12+i-8)
      :' ^      ^       ^-- get an ascii value from the middle of d$
      :' |      |           and convert it to a frequency (Hz)
      :' |      +-- base frequency A=440Hz, adjusted slightly
      :' +-- populate m(1) to m(20), but only use 17 notes
    next
  next
  for i=1to 17:s(m(i)):next       :' ascend
  for i=1to 16:s(m(17-i)):next    :' descend
next
sub s(x):sound x,.2,50:return

677 bytes

Chipmunk Basic, 677 303 280 241 228 bytes

dim m(20):d$="GIKNDFGKGIKNDFGK@BDGBDFICGJNEILP":for k=0to 7
for i=0to 4:for o=1to 4:m(o+4*i)=555*2^(asc(mid$(d$,k*4+o))/12+i-8):next:next
for i=1to 17:s(m(i)):next:for i=1to 16:s(m(17-i)):next:next
sub s(x):sound x,.2,50:return

The info about chords and octaves in the "music theory" section helped a lot.
Ungolfed:

dim m(20)
d$="GIKNDFGKGIKNDFGK@BDGBDFICGJNEILP"
for k=0to 7                       :' the 8 chords
  for i=0to 4                     :' ascend arpeggio for 5 octaves
    for o=1to 4                   :' broken into 4 notes
      m(o+4*i)=555*2^(asc(mid$(d$,k*4+o))/12+i-8)
      :' ^      ^       ^-- get an ascii value from the middle of d$
      :' |      |           and convert it to a frequency (Hz)
      :' |      +-- base frequency A=440Hz, adjusted slightly
      :' +-- populate m(1) to m(20), but only use 17 notes
    next
  next
  for i=1to 17:s(m(i)):next       :' ascend
  for i=1to 16:s(m(17-i)):next    :' descend
next
sub s(x):sound x,.2,50:return

677 bytes

Chipmunk Basic, 677 303 280 241 228 bytes

dim m(20):d$="GIKNDFGKGIKNDFGK@BDGBDFICGJNEILP":for k=0to 7
for i=0to 4:for o=1to 4:m(o+4*i)=555*2^(asc(mid$(d$,k*4+o))/12+i-8):next:next
for i=1to 17:s(m(i)):next:for i=1to 16:s(m(17-i)):next:next
sub s(x):sound x,.2,50:return

Try the debug version on TutorialsPoint!

The info about chords and octaves in the "music theory" section helped a lot.
Ungolfed:

dim m(20)
d$="GIKNDFGKGIKNDFGK@BDGBDFICGJNEILP"
for k=0to 7                       :' the 8 chords
  for i=0to 4                     :' ascend arpeggio for 5 octaves
    for o=1to 4                   :' broken into 4 notes
      m(o+4*i)=555*2^(asc(mid$(d$,k*4+o))/12+i-8)
      :' ^      ^       ^-- get an ascii value from the middle of d$
      :' |      |           and convert it to a frequency (Hz)
      :' |      +-- base frequency A=440Hz, adjusted slightly
      :' +-- populate m(1) to m(20), but only use 17 notes
    next
  next
  for i=1to 17:s(m(i)):next       :' ascend
  for i=1to 16:s(m(17-i)):next    :' descend
next
sub s(x):sound x,.2,50:return

677 bytes

deleted 251 characters in body
Source Link
roblogic
  • 4.7k
  • 22
  • 25

Chipmunk Basic, 677 303 280 241241 228 bytes

dim m(20):d$="GIKN DFGK GIKN DFGK @BDG BDFI CGJN EILP"
d$="GIKNDFGKGIKNDFGK@BDGBDFICGJNEILP":for k=1tok=0to 8:7
for i=0to 4:for o=1to 4
 :m(o+4*i)=555*2^(asc(mid$(field$(d$,k),ok*4+o))/12+i-8):next:next
for i=1to 17:s(m(i)):next:for i=1to 16:s(m(17-i)):next:next
sub s(x):sound x,.2,50:return

The info about chords and octaves in the "music theory" section helped a lot.
Debug version (outdated)Ungolfed:

data 0,2,4,7,-3,-1,0,4,0,2,4,7,-3,-1,0,4,-7,-5,-3,0,-5,-3,-1,2,-4,0,3,7,-2,2,5,9
dim a(4),m(1620)
d$="GIKNDFGKGIKNDFGK@BDGBDFICGJNEILP"
for k=0to 7                       :' dothe 8 timeschords
  for i=1to 4:read a(i):next      :' read nexti=0to 4 notes into array a
  t(a)                            :' call theascend arpeggio subroutine, t
next

subfor t(o)5 octaves
    for o=1to 4                   :' o is an octave (arraybroken ofinto 4 notes, n)
  for i=0to 3                     :' i goes up the octaves m(steps of 12o+4*i)=555*2^(asc(mid$(d$,k*4+o))/12+i-8)
  for j=1to 4     :' ^      ^       ^-- get :'an jascii runsvalue thrufrom the notesmiddle inof od$
    n=o(j)+12*i:print n;          :' n is the| note number, incl factor
  |  f=440*2^((n-21)/12)         and convert :'it fto isa frequency of n (Hz)
    m(j+4*i)=f  :' |      +-- base frequency A=440Hz, adjusted slightly
      :' Add f to+-- arraypopulate m
    s(f1)   to m(20), but only use 17 notes
    next
  next
  for i=1to 17:s(m(i)):next       :' Play f (Up)
  next:nextascend
  for i=1to 1516:s(m(1617-i)):next    :' Play m (Down)
  print
returndescend
next
sub s(nx)
  :sound nx,.12,50
 :return

677 bytes : I am sure there is a better way of coding this ...

Chipmunk Basic, 677 303 280 241 bytes

dim m(20):d$="GIKN DFGK GIKN DFGK @BDG BDFI CGJN EILP"
for k=1to 8:for i=0to 4:for o=1to 4
 m(o+4*i)=555*2^(asc(mid$(field$(d$,k),o))/12+i-8):next:next
for i=1to 17:s(m(i)):next:for i=1to 16:s(m(17-i)):next:next
sub s(x):sound x,.2,50:return

The info about chords and octaves in the "music theory" section helped a lot.
Debug version (outdated):

data 0,2,4,7,-3,-1,0,4,0,2,4,7,-3,-1,0,4,-7,-5,-3,0,-5,-3,-1,2,-4,0,3,7,-2,2,5,9
dim a(4),m(16)

for k=0to 7                       :' do 8 times
  for i=1to 4:read a(i):next      :' read next 4 notes into array a
  t(a)                            :' call the arpeggio subroutine, t
next

sub t(o)                          :' o is an octave (array of 4 notes, n)
  for i=0to 3                     :' i goes up the octaves (steps of 12)
  for j=1to 4                     :' j runs thru the notes in o
    n=o(j)+12*i:print n;          :' n is the note number, incl factor
    f=440*2^((n-21)/12)           :' f is frequency of n (Hz)
    m(j+4*i)=f                    :' Add f to array m
    s(f)                          :' Play f (Up)
  next:next
  for i=1to 15:s(m(16-i)):next    :' Play m (Down)
  print
return

sub s(n)
  sound n,.1,50
 return

677 bytes : I am sure there is a better way of coding this ...

Chipmunk Basic, 677 303 280 241 228 bytes

dim m(20):d$="GIKNDFGKGIKNDFGK@BDGBDFICGJNEILP":for k=0to 7
for i=0to 4:for o=1to 4:m(o+4*i)=555*2^(asc(mid$(d$,k*4+o))/12+i-8):next:next
for i=1to 17:s(m(i)):next:for i=1to 16:s(m(17-i)):next:next
sub s(x):sound x,.2,50:return

The info about chords and octaves in the "music theory" section helped a lot.
Ungolfed:

dim m(20)
d$="GIKNDFGKGIKNDFGK@BDGBDFICGJNEILP"
for k=0to 7                       :' the 8 chords
  for i=0to 4                     :' ascend arpeggio for 5 octaves
    for o=1to 4                   :' broken into 4 notes
      m(o+4*i)=555*2^(asc(mid$(d$,k*4+o))/12+i-8)
      :' ^      ^       ^-- get an ascii value from the middle of d$
      :' |      |           and convert it to a frequency (Hz)
      :' |      +-- base frequency A=440Hz, adjusted slightly
      :' +-- populate m(1) to m(20), but only use 17 notes
    next
  next
  for i=1to 17:s(m(i)):next       :' ascend
  for i=1to 16:s(m(17-i)):next    :' descend
next
sub s(x):sound x,.2,50:return

677 bytes

deleted 21 characters in body
Source Link
roblogic
  • 4.7k
  • 22
  • 25

Chipmunk Basic, 677 303 280280 241 bytes

data 0,2,4,7,-3,-1,0,4,0,2,4,7,-3,-1,0,4,-7,-5,-3,0,-5,-3,-1,2,-4,0,3,7,-2,2,5,9
dim a(4),m(1620):ford$="GIKN k=0toDFGK 7:forGIKN i=1toDFGK 4:read@BDG a(i):nextBDFI CGJN EILP"
for i=0tok=1to 38:for j=1toi=0to 4:f=440*2^for o=1to 4
m(o+4*i)=555*2^(asc(mid$(afield$(jd$,k)+12*i,o)-21)/1212+i-8):m(j+4*i)=fnext:next
for i=1to 17:s(fm(i)):next:next
for i=1to 1516:s(m(1617-i)):next:next
sub s(nx):sound nx,.152,50:return

The info about chords and octaves in the "music theory" section helped a lot.
More readable, debugDebug version (outdated):

Chipmunk Basic, 677 303 280 bytes

data 0,2,4,7,-3,-1,0,4,0,2,4,7,-3,-1,0,4,-7,-5,-3,0,-5,-3,-1,2,-4,0,3,7,-2,2,5,9
dim a(4),m(16):for k=0to 7:for i=1to 4:read a(i):next
for i=0to 3:for j=1to 4:f=440*2^(((a(j)+12*i)-21)/12):m(j+4*i)=f:s(f):next:next
for i=1to 15:s(m(16-i)):next:next
sub s(n):sound n,.15,50:return

The info about chords and octaves in the "music theory" section helped a lot.
More readable, debug version:

Chipmunk Basic, 677 303 280 241 bytes

dim m(20):d$="GIKN DFGK GIKN DFGK @BDG BDFI CGJN EILP"
for k=1to 8:for i=0to 4:for o=1to 4
m(o+4*i)=555*2^(asc(mid$(field$(d$,k),o))/12+i-8):next:next
for i=1to 17:s(m(i)):next:for i=1to 16:s(m(17-i)):next:next
sub s(x):sound x,.2,50:return

The info about chords and octaves in the "music theory" section helped a lot.
Debug version (outdated):

added 32 characters in body
Source Link
roblogic
  • 4.7k
  • 22
  • 25
Loading
added 895 characters in body
Source Link
roblogic
  • 4.7k
  • 22
  • 25
Loading
deleted 277 characters in body
Source Link
roblogic
  • 4.7k
  • 22
  • 25
Loading
Source Link
roblogic
  • 4.7k
  • 22
  • 25
Loading