Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:37 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Generative Music Demo

Author Message
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 09:51pm 26 Sep 2020
Copy link to clipboard 
Print this post

I feel a bit shy about posting this one. For one thing, lots of people hate algorithmic so-called "music", and I fully understand this opinion. For another, my specific choice of a demo composition is understandably not to everybody's taste, although I kind of like it.

In any event, this composition is a passacaglia over a 4-note ground bass obligato, with 3 treble voices singing pretty much same same rising scale, but with varying note durations that get mixed by a little state machine.

There is no ending; it just keeps playing until you get bored and throttle it.

-Bill


GenMusic1.zip
 
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 11:24pm 26 Sep 2020
Copy link to clipboard 
Print this post

It's interesting: my el cheapo speakers have horrible intermodulation distortion and resonances all over the place. For some reason, this distortion actually makes the music more interesting (to my ear), unless I turn the volume up too high, in which case it degenerates into a very unappealing mess.

Like the man says, your mileage may vary.

If I can find them, I am going to try changing from square-wave tones to sampled piano keys; it should make things sound better.

-Bill
 
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 719
Posted: 03:58pm 27 Sep 2020
Copy link to clipboard 
Print this post

Your piece is delightful ! ....  

> algorithmic so-called "music"

Can definitely be quite musical .
Since music is in the ear of the beholder ,
algorithms can become what I would call
" artificial musical intelligence "  

> I am going to try changing from square-wave
> tones to sampled piano keys

To me it is not the wave squareness , but the
lack of any envelopes that is the main lack .
Samples would be one way to overcome that for sure .
my site
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 05:49pm 27 Sep 2020
Copy link to clipboard 
Print this post

This is really interesting!  

I agree about the distortion on small cheap speakers.  I find that using Sine or Triangle waves have much less distortion, this makes sense as the sharp rise and fall time of the square wave have tons of harmonics.
-Carl
 
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 06:31pm 27 Sep 2020
Copy link to clipboard 
Print this post

Square waves have tons of harmonics too. The difference is that triangle waves have only odd harmonics. If you look at the fourier transform of a triangle wave, you will see a series of peaks starting at 3 and descending in amplitude as the harmonic number gets higher, but the peaks are only add odd harmonic numbers.

The situation with square waves is harder to describe neatly. The fourier transform of a square wave is a 'sinc' (sine(x)/x) function.

I agree with you about the need for an envelope. The computer-generated tones seem lifeless because they have no attack or delay; they just suddenly start and suddenly stop with no amplitude variation.

Pianos have a ton of harmonics as well as an envelope, and the timbre depends a lot on how hard the note is struck.

So far I have not been able to find a full set of royalty-free piano note sound clips online. If I get desperate I can probably make my own from my digital piano.

-Bill
 
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 06:38pm 27 Sep 2020
Copy link to clipboard 
Print this post

I found a couple of minor bugs in GenMusic1.bas after posting it. The attached version has those fixed. I also split the voices into left and right channels, which helps the intermodulation distortion a little.

-Bill

GenMusic1.zip
 
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 719
Posted: 08:11pm 27 Sep 2020
Copy link to clipboard 
Print this post

How ' bout this ?
my site
 
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 08:36pm 27 Sep 2020
Copy link to clipboard 
Print this post

I've heard about generative music but this demo illustrates the concept more clearly than most of what I came across online.
It's great stuff like this that I was hoping for when I bought my Maximite 2. I'm not disappointed. Very cool!      
Epsilon CMM2 projects
 
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 719
Posted: 11:23pm 29 Sep 2020
Copy link to clipboard 
Print this post


'''''' Island '''''''                    
dim c(3),m(7),p(7),v(7)
for i=0 to 3: read c(i): next i
for i=0 to 7: read m(i): next i
for i =0 to 7:read v(i): next i
for i=0 to 7: read p(i): next i
data 8,6,9,6, 2,2,4,4,3,3,4,4
data 1,0,1,0,1,0,1,0
data 4,0,2,2,9,0,2,2

do: for x=0 to 3

play sound 1,b,t,16*c(x),5
play sound 2,b,t,24*c(x),5

for y=0 to 7: n=(c(x)*m(y))

play sound 3,b,s,1024,p(y)
pause 10: play sound 3,b,o

select case int(rnd * 3)

case 0: play sound 4,b,q,4*n,9*v(y)
pause 120: play sound 4,b,o: pause 10

case 1: play sound 4,b,w,8*n,9*v(y)
pause 70: play sound 4,b,o: pause 60

case 2: play sound 4,b,q,16*n,7*v(y)
pause 20: play sound 4,b,o: pause 110

end select: next y: next x: loop

my site
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 10:10am 01 Oct 2020
Copy link to clipboard 
Print this post

  William Leue said  I found a couple of minor bugs in GenMusic1.bas after posting it. The attached version has those fixed. I also split the voices into left and right channels, which helps the intermodulation distortion a little.

-Bill

GenMusic1.zip


Hey Bill,

What are your thoughts on me including this on the "Welcome Tape" distributed under the "Unlicense" - it is more than a little short on sound demos.

Best wishes,

Tom
Edited 2020-10-01 20:12 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 03:12pm 02 Oct 2020
Copy link to clipboard 
Print this post

Tom, you are welcome to add GenMusic1 to the Welcome Tape! As always, I am honored to be considered.

BTW, I have a newer version coming out in a day or two; a couple more bug fixes and some tinkering with the timbre for better-sounding output. I will post when it is ready.

-Bill
 
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 08:12pm 02 Oct 2020
Copy link to clipboard 
Print this post

Attached is version 1.0.2 of GenMusic1.

I found out that Sasquatch was correct: triangular waves generate less intermodulation distortion on cheap speakers than square waves, so I changed to triangular. There are also some minor graphics warts fixed.

I did try generating MIDI from this composition by outputting a text file in CSV format and then using csvmidi.exe to convert the output to real binary MIDI. But the result just did not sound good, so I gave up.

This will likely be the final version of GenMusic, although I may try other algorithms.

-Bill


GenMusic1.zip
 
Herry

Senior Member

Joined: 31/05/2014
Location: Australia
Posts: 261
Posted: 06:44am 04 Oct 2020
Copy link to clipboard 
Print this post

  William Leue said  Square waves have tons of harmonics too.


Fourier would say infinite!
Senior?!  Whatever it says, I'm a complete and utter beginner...
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025