Skip to main content
deleted 5 characters in body
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385

A for each loop ("...]) reads each note, represented by the corresponding number S. To generate the waveform for eachthe note, a time vector [1 2 ... 1875] is first generatedcreated (1875:). The length of this vector, when replayed at 10000 samples per second, determines a tempo of 80 bpm, as required. This vector is element-wise multiplied by 2*pi (YPE*), divided by 76 (76/), and then multiplied by 2 raised to the number that results from dividing S by 12 (@12/W*). Applying the sine function (Y,) produces a 1×1875 vector with samples of a sinusoid of the frequency correponding to S. The values of this vector are multiplied by 2 (E). The last sinusoid contains NaN values and will produce no sound.

A for each loop ("...]) reads each note, represented by the corresponding number S. To generate the waveform for each note, a time vector [1 2 ... 1875] is first generated (1875:). The length of this vector, when replayed at 10000 samples per second, determines a tempo of 80 bpm, as required. This vector is element-wise multiplied by 2*pi (YPE*), divided by 76 (76/), and then multiplied by 2 raised to the number that results from dividing S by 12 (@12/W*). Applying the sine function (Y,) produces a 1×1875 vector with samples of a sinusoid of the frequency correponding to S. The values of this vector are multiplied by 2 (E). The last sinusoid contains NaN values and will produce no sound.

A for each loop ("...]) reads each note, represented by the corresponding number S. To generate the waveform for the note, a time vector [1 2 ... 1875] is first created (1875:). The length of this vector, when replayed at 10000 samples per second, determines a tempo of 80 bpm, as required. This vector is element-wise multiplied by (YPE*), divided by 76 (76/), and then multiplied by 2 raised to the number that results from dividing S by 12 (@12/W*). Applying the sine function (Y,) produces a 1×1875 vector with samples of a sinusoid of the frequency correponding to S. The values of this vector are multiplied by 2 (E). The last sinusoid contains NaN values and will produce no sound.

added 26 characters in body
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385

A 0Number 0 is first pushed to the stack. This will serve as the initial note. The rest of the notes will be defined by consecutive differences, measured in semitones.

A 0 is first pushed to the stack. This will serve as the initial note. The rest of the notes will be defined by consecutive differences.

Number 0 is first pushed to the stack. This will serve as the initial note. The rest of the notes will be defined by consecutive differences, measured in semitones.

deleted 87 characters in body
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385

MATL (1 language), 7878 77 bytes

0'!4XC@nRAxt~&'F5:ZaKe16:Y)tP[AaABOlHN]0YZaKeK1X"tP[AaABOlHN]0Y(_&vhYs"1875:YPE*76/@12/W*Y,E]&h1e4Y#

Try it at MATL onlineMATL online!

To generate this matrix, the string '!4XC@nRAxt~&' is interpreted as a "number" in the base defined by all ASCII characters except single quote, and is decoded into the base formed by the numbers [1 2 3 4 5], producing a row vector (this operation is done by the code F5:Za). ConvertingReshaping this to awith 4-row matrix rows (Ke) gives the above matrix. Then, the matrix is repeatedextended by replicating it 4 times vertically (K1X"), because each ascending arpeggio is played 4 times. This is carried out by applying modular indexing from 1 to 16 into the rows of the above matrix (code 16:Y)), which yields a 16×8 matrix.

MATL (1 language), 78 bytes

0'!4XC@nRAxt~&'F5:ZaKe16:Y)tP[AaABOlHN]0Y(_&vhYs"1875:YPE*76/@12/W*Y,E]&h1e4Y#

Try it at MATL online!

To generate this matrix, the string '!4XC@nRAxt~&' is interpreted as a "number" in the base defined by all ASCII characters except single quote, and is decoded into the base formed by the numbers [1 2 3 4 5], producing a row vector (this operation is done by the code F5:Za). Converting this to a 4-row matrix (Ke) gives the above matrix. Then, the matrix is repeated 4 times vertically, because each ascending arpeggio is played 4 times. This is carried out by applying modular indexing from 1 to 16 into the rows of the above matrix (code 16:Y)), which yields a 16×8 matrix.

MATL (1 language), 78 77 bytes

0'!4XC@nRAxt~&'F5:ZaKeK1X"tP[AaABOlHN]0Y(_&vhYs"1875:YPE*76/@12/W*Y,E]&h1e4Y#

Try it at MATL online!

To generate this matrix, the string '!4XC@nRAxt~&' is interpreted as a "number" in the base defined by all ASCII characters except single quote, and is decoded into the base formed by the numbers [1 2 3 4 5], producing a row vector (this operation is done by the code F5:Za). Reshaping this with 4 rows (Ke) gives the above matrix. Then, the matrix is extended by replicating it 4 times vertically (K1X"), because each ascending arpeggio is played 4 times. This yields a 16×8 matrix.

deleted 2 characters in body
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385
Loading
added 3228 characters in body
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385
Loading
added 3228 characters in body
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385
Loading
added 3228 characters in body
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385
Loading
added 3228 characters in body
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385
Loading
uewncy
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385
Loading
uewncy
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385
Loading
deleted 14 characters in body
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385
Loading
deleted 14 characters in body
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385
Loading
Source Link
Luis Mendo
  • 106.9k
  • 10
  • 142
  • 385
Loading