Author |
Message |
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Mon Sep 12, 2016 12:07 am Post subject:
Calculate chords with an arduino Subject description: and output them with an YM2149 |
|
|
In my (ahum) younger days I played a lot with the AY-3-8910 musical interface chip.
This chip holds three frequency generators, a noise generator and an envelope generator which can be controlled by a simple micro processor (while I used a 6502 "in the early days", now I'm planning to use an Arduino).
A few weeks ago I ordered and received a "clone" from this chip: the Yamaha YM2149.
They sell for 2 pcs for 2.50€
I think it would be great to have a module where I can send a midi note and the processor calculates a triad chord in such a way that it actually sounds like music and not like some casual random chords following each other.
I could enter a row of chords that sounds like a song (or actually IS a song), but that's not what I'm looking for,
What I am looking for is some kind of recipe for a sequence of triad chords that sounds like music, but still in a random fashion
I would like to "calculate" the next chord, considering the previous one(s).
Hope I'm making sense?
Anybody ever worked with this, have ideas about this or even reading stuff? That would greatly be appreciated! |
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Mon Sep 12, 2016 6:39 am Post subject:
|
|
|
[removed due to personal reasons] Last edited by MusicMan11712 on Tue Nov 15, 2016 8:58 pm; edited 1 time in total |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24079 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Mon Sep 12, 2016 10:59 am Post subject:
|
|
|
Markov chains maybe?
Those have a learning mode (you could seed 'm with a song you like) and then it can make chance driven variations on what was learned. _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Tue Sep 13, 2016 12:15 am Post subject:
|
|
|
I sort of got carried away in my starting post: The main idea is to supply a sequence of midi notes (from a sequencer or keyboard) to a module which is (more or less) a melody to start with, not a stand alone melody making device.
@Blue Hell: Markov chains is an algorithm that describes the possibilities for each step independent of the previous condition.
In music terms it calculates the next note without considering the previous note.
This is indeed possible to use but it is half the problem, I need a sequence of triades dependent on the previous notes (some, maybe 3?)
And true, MusicMan11712, I could use just Major triades, or Minors or what have you, but I would still need an algorithm that tells me what kind of triade is best used after (some) previous triades.
Just using Majors (or Minors, or..) makes it again boring after some time. |
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Tue Sep 13, 2016 11:17 am Post subject:
|
|
|
[removed due to personal reasons] Last edited by MusicMan11712 on Tue Nov 15, 2016 8:58 pm; edited 1 time in total |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Thu Sep 15, 2016 11:27 am Post subject:
|
|
|
[removed due to personal reasons] Last edited by MusicMan11712 on Tue Nov 15, 2016 8:58 pm; edited 1 time in total |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Fri Sep 16, 2016 2:15 am Post subject:
|
|
|
Haskell is unknown to me... sorry
I started this tread to generate ideas and do some research in the matter.
That's how I do things when I have an idea, in this way I can be busy with the hobby without being building all the time.
There is a build I have to finish before I can really dig into this topic, until than I keep reading and collecting material about the generation of artificial music. |
|
Back to top
|
|
|
cyclic
Joined: Mar 15, 2015 Posts: 95 Location: hobart
|
Posted: Fri Sep 16, 2016 3:23 am Post subject:
|
|
|
So, I know nothing about programming and almost nothing about music theory. Maybe my ideas are hopeless, or maybe I'll come in with outsiders eyes...
I am interested in your project though..
Can you just created a table (or tables) of the relevant chord frequencies, and then have the progression be based on a movement through or across the table itself, rather than mathematically computed. So it might start with Cmaj in the middle and then selectable move, say diagonally 45deg to step through the chords, with options for step size, angle of step etc.
Or say, use a Fibonacci or a parabolic path to step through x times and then jump to a new table based on its current position.
Obviously then the structure of the table would be Paramount to the final outcome.
Cheers
Lance |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Fri Sep 16, 2016 4:24 am Post subject:
|
|
|
I have C++ code to calculate the frequency from a given midi note.
No problem.
I know that the major triade chord of a given note (ROOT) is ROOT ROOT+6 ROOT+10, if ROOT = C than: C E G
A minor triade is ROOT ROOT+4 ROOT+10
That's the easy part.
The problem is how to have a sequence of Major Minor Augmented Diminished Suspended triads from a given melody that makes sense. |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Fri Sep 16, 2016 4:32 am Post subject:
|
|
|
EL BO wrote: | Can you just created a table (or tables) of the relevant chord frequencies |
I think this is one way to go, make a table or code for Major Minor Augmented Diminished Suspended triads, and just listen what chords sounds good following a previous one.
Make this a table too and add some degree of randomization to it..
Hmmzzz.... |
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Fri Sep 16, 2016 11:11 am Post subject:
|
|
|
[removed due to personal reasons] Last edited by MusicMan11712 on Tue Nov 15, 2016 8:58 pm; edited 1 time in total |
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Fri Sep 16, 2016 11:23 am Post subject:
|
|
|
[removed due to personal reasons] Last edited by MusicMan11712 on Tue Nov 15, 2016 8:59 pm; edited 1 time in total |
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Fri Sep 16, 2016 11:30 am Post subject:
|
|
|
[removed due to personal reasons] Last edited by MusicMan11712 on Tue Nov 15, 2016 8:59 pm; edited 1 time in total |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Sat Sep 17, 2016 12:39 am Post subject:
|
|
|
First of all: I have made a mistake by looking at the wrong table: A Major Triade consists of the ROOT, ROOT+4 and ROOT+7, where +4 and +7 are full midi steps.
Expl: a C Major Triade Chord consists of the notes C, E and G, looking at the upper figure that are the midi notes 60, 64 and 67.
If I want to calculate a Major Triade for F# (being midi note 66) I just add 4 and 7 to get the Major for F# (F#, A# and C#)
For the Minor Chords the calculation is the same but I just have to add 3 and 7 to the ROOT, so for a C Minor Chord Triade the midi notes 60, 63 and 67 are used, being C, E♭ (D#) and G.
So as far as programming the chords concerns that is the easy part.
As far as the "good sounding" chords following each other my guess is that I just have to start listening to what sounds good and try to figure out some kind of rule set that will create an ok sounding sequence of triades made of a GIVEN sequence of notes.
Quote: | Steve wrote: Here is where I think the article might help you--instead of making tables (or arrays) of acceptable triad and acceptable sequences of triads you could have arrays of acceptable progressions (chord changes) and acceptable tones for inserting into the progression--passing tones, neighboring tones, etc. with weighted randomization percentages. | This!
Description: |
In this table, the chord names are in the left-most column. The chords are given in root position. For a given chord name, the following three columns indicate the individual notes that make up this chord. Thus in the first row, the chord is C Major, whic |
|
Filesize: |
8.82 KB |
Viewed: |
23744 Time(s) |
|
Description: |
In this picture you see the connection between midi notes, note names, bars, frequency and pitch |
|
Filesize: |
8.75 KB |
Viewed: |
23744 Time(s) |
|
|
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Sat Sep 17, 2016 4:43 am Post subject:
|
|
|
[removed due to personal reasons] Last edited by MusicMan11712 on Tue Nov 15, 2016 8:59 pm; edited 1 time in total |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Sat Sep 17, 2016 5:22 am Post subject:
|
|
|
Sure, moving to the Arduino forum is fine to me since I plan to use an Arduino (clone) anyway.
The only thing is that I don't use the Arduino platform, but Atmel Studio instead.
Just ordered 5 more YM2149's to play with. Now I have just one.
The plan is to maybe have 3 controlled by an Arduino because than it is possible to use a different envelope for each note in a triad.
But first start with one
I like the way this is g(r)oing, more ideas to think about like choice of music type, effect of randomness and number of notes in a chord.
By adding more notes to a chord, the number of posibilities grow exponentially I guess? |
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Sat Sep 17, 2016 6:05 am Post subject:
|
|
|
[removed due to personal reasons] Last edited by MusicMan11712 on Tue Nov 15, 2016 8:59 pm; edited 1 time in total |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Sat Sep 17, 2016 12:43 pm Post subject:
|
|
|
I think it's most convenient to first work with midi, they go from 0 to 127, so an 8 bit word will suffice, that's fast because you just have to add 4 and 7 to a given midi number to get the major triade.
With these three numbers you can take the three frequency's from an array that's only 127 words in size.
And the C++ code is written using Atmel Studio. The reason I use Atmel Studio is because the Arduino IDE takes so much into account that it gets relatively slow.
This whole idea started when I was thinking about a way to make the sounds from my sequencer a little more interesting and pleasant to listen to.
So I thought of randomizing the pitch-bend, but that sounded really artificial, much like a sample and hold that feeds a VCO. |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Mon Sep 19, 2016 10:56 pm Post subject:
|
|
|
Jan was kindly enough to relocate this thread to the Arduino sub-forum, Thanks Jan.
Yesterday I ordered two Arduino Uno R3 clones with the 16u2 on board.
This has two advantages: one: the 16u2 takes care of the usb communication, so I don't have to worry about a 'bad' FTDI driver that will brick my knock off usb chip.
Two: the 16u2 can be programmed in a way that the computer sees it as an genuine midi device!
So I decided to wait for the arrival of these boards and in the mean while maybe I can finish my echo/reverb board and when the boards arrive use Steve's code for a starting point, if that's ok?
In that way, I first use midi to my computer and add hardware tone generation later. |
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Tue Sep 20, 2016 2:52 am Post subject:
|
|
|
[removed due to personal reasons] Last edited by MusicMan11712 on Tue Nov 15, 2016 9:00 pm; edited 1 time in total |
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Tue Sep 20, 2016 2:59 am Post subject:
|
|
|
[removed due to personal reasons] Last edited by MusicMan11712 on Tue Nov 15, 2016 9:00 pm; edited 1 time in total |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Tue Sep 20, 2016 4:25 am Post subject:
|
|
|
The Uno with the midi program installed will still communicate with the standard 31.25kbps and another problem: I use the hex file to turn the Uno in a midi device. There is a GIthub: https://github.com/ddiakopoulos/hiduino with the files, but I'm unable to change the firmware and thus unable to change the name of the individual Arduino. |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Tue Sep 20, 2016 5:51 am Post subject:
|
|
|
Found a WEBSITE where I can change the name of the midi device made with an UNO or MEGA |
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Tue Sep 20, 2016 11:56 am Post subject:
|
|
|
Will renaming trick work with a genuine arduino? If so, that might be cool to have several hooked up and have names for them! As for 31.25 kbaud--yeah, that's good to communicate with 1980-2010 era midi gear, buy why do that when you can communicate via software or your own arduino-based midi processor or synth at 115200 kbaud (or whatever the max is)?
I mean, if I built a midi-capable synth using a modern microprocessor, I'd want it to break the 31.25 kbaud standard from 1980!! |
|
Back to top
|
|
|
|