Feature Request: 'Chord' in sound library + proposal

Libraries, utilities, bootloaders...

Feature Request: 'Chord' in sound library + proposal

Postby yv2149 » Mon Jan 19, 2015 3:52 pm

Hi all,

It is common in chip music effects to have chords, which is a round-robin arpeggio over up to 3 notes, switching quickly between them.
For instance, a C major chord would be a C note with chord command and parameters 4 (C+4 semitones==E) and 7 (C+7 semitones==G).
Unless I'm mistaken, this feature is fairly missing in the Gamebuino sound library.
Currently, arpeggio can be achieved with command ID 3. But on its own, except for audio glitching or oldschool laser sound effects, it cannot really be used for musical purposes.

To add chord feature to Gamebuino Sound lib, a non-intrusive API addition would be to add a new command ID, 'Arpeggio2', that gives a second arpeggio step size and step duration to Gamebuino, pretty much like 'Arpeggio' already does.

When both commands are sent, the Gamebuino would switch between regular Note base, then 'Arpeggio' note offset after 'Arpeggio' step duration, then 'Arpeggio2' note offset after 'Arpeggio2' step duration. This way we can achieve a 3 notes chord with a simple API addition, plus the ability to have 1 step duration per arpeggio/arpeggio2 command, which gives the feature of having chords with variable individual step durations: pure chord awesomeness.

Rodot, what do you think?
If this is convenient to you, could you give an ETA for this feature to appear in the sound library?

Thanks,
yv2149.
yv2149
 
Posts: 3
Joined: Mon Jan 19, 2015 3:18 pm

Re: Feature Request: 'Chord' in sound library + proposal

Postby jonnection » Tue Jan 20, 2015 8:57 am

Just a note about arpeggios, and something to consider in how to implement them in Gamebuino.

To play the arpeggios in the scale of C major (for example) you also have to have chords D minor, E minor and A minor.
You need both tonic+4th+7th arpeggio for major chords and tonic+3rd+7th for minor chords. Otherwise you can't do chord progressions properly.

The way I have done this in my tracker is I have 2 identical instruments, one playing major arpeggios and other minor arpeggios. Then in the pattern I use both instruments according to the key. It is not the most user-friendly way to do it, but I have optimized for minimum memory usage and this is why I chose that approach. In traditional trackers you could specify intervals and speed of arpeggio in the extended note data, but that requires more memory per note to implement.

Also, I have noticed that 0,4,7,4,0 (ping-pong) sounds better than 0,4,7,0,4,7 (climbing loop) ... it is more like a chord and less like a laser. The ability to set the speed of arpeggio is also a good feature to have.
User avatar
jonnection
 
Posts: 317
Joined: Sun May 04, 2014 8:21 pm

Re: Feature Request: 'Chord' in sound library + proposal

Postby yv2149 » Sat Jan 31, 2015 4:32 pm

Hello Rodot,

Did you have time to check this nice topic?
I believe chord feature is essential for doing chiptunes properly, all trackers have it one way or another.
Would my API proposal in 1st post be feasible ? Not too code expensive?

Thanks,
yv2149
yv2149
 
Posts: 3
Joined: Mon Jan 19, 2015 3:18 pm

Re: Feature Request: 'Chord' in sound library + proposal

Postby rodot » Sun Feb 01, 2015 7:58 am

Hey,
That's a very good idea, although the way you suggest won't allow "ping-pong" arpeggios, or 4 notes arpeggios, etc. There will still be a point where you'll say "Damn, we should add Argpeggio3 and Argpeggio4 too!". That's why there is the "instrument" layer under the "pattern" layer, to allow you to create custom chords with as many steps as you want, with the duration and the pitch offset you want (as suggested Jonnection). Would that be ok with you? The problem with this approach is that it won't allow to use both complex instruments + arpeggios at the same time.
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Feature Request: 'Chord' in sound library + proposal

Postby yv2149 » Wed Feb 04, 2015 5:35 pm

Hi Rodot,

Thanks for answering on this topic.

Looking at the xls spec file/"instru encoding" sheet, unless I am mistaken, I can't really see how to create unlimited chords within fixed 2x16 bits per instrument.
Particularly, step word/pitch envelope (bits 10-15) only exposes 1 pitch step field, which would only fit a chord of 2 notes.

If you don't mind, could you please give a binary example of an instrument with 3 notes chord? 4 notes chord?

Thanks,
yv2149
yv2149
 
Posts: 3
Joined: Mon Jan 19, 2015 3:18 pm

Re: Feature Request: 'Chord' in sound library + proposal

Postby rodot » Sun Feb 08, 2015 3:35 pm

Each instrument has 1 header word, plus any number of steps. They are made this way :
insrument encoding.PNG
insrument encoding.PNG (13.83 KiB) Viewed 4946 times


For example, you could create the following instrument :
arpeggio table.PNG
arpeggio table.PNG (3.99 KiB) Viewed 4946 times


The header word could be 0x24 : 4 because there is 4 steps, and 2 to loop on the 2 last steps.

Which would give the instrument :
Code: Select all
PROGMEM uint16_t myInstrument[] = {0x0204,0x22,0x1025,0x1C27,0x1025,};


Here is a SSCCE which plays the instrument when "A" is pressed:

Code: Select all
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;

//declare different instruments
const uint16_t squareWaveInstrument[] PROGMEM = {
  0x0101, 0x03F7};
const uint16_t noiseInstrument[] PROGMEM = {
  0x0101, 0x03FF};
const uint16_t arpeggioInstrument[] PROGMEM= {
  0x0404,0x22,0x1025,0x1C27,0x1025};

//make an instruemnt set with these instruments
const uint16_t* const myInstrumentSet[] PROGMEM = {
  squareWaveInstrument,noiseInstrument,arpeggioInstrument};


void setup()
{
  gb.begin();
  gb.titleScreen(F("Music demo"));

  //load the instrument set on channel 0
  gb.sound.changeInstrumentSet(myInstrumentSet, 0);


}

void loop()
{
  if(gb.update()){
    if(gb.buttons.pressed(BTN_A)){
      //command 1 : select instrument
      //X 2 : instrument ID of the arpeggio instrument
      //Y 0 : no need of second parameter for this command
      //channel 0
      gb.sound.command(CMD_INSTRUMENT,2,0, 0);
      //14 : ID of C3
      //20 : duration in number of frame
      //0 : channel 0
      gb.sound.playNote(14, 40, 0);
    }
  }
}
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France


Return to Software Development

Who is online

Users browsing this forum: No registered users and 21 guests

cron