Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Musical notation question

Status
Not open for further replies.

3v0

Coop Build Coordinator
Forum Supporter
My knowledge of music is limited.

I have been playing with a program that is much like a simple electronic organ. More like a kazoo. Fun stuff. :)

You can encode a tune by call playNote(duration, note) as needed.

The following plays an octave of full notes

Code:
  playNote(100, C);
  playNote(100, Db);
  playNote(100, D);
  playNote(100, Eb);
  ...
  playNote(100, Bb);
  playNote(100, B);
  playNote(100, C);  // <--- problem here
This notation is limited to one octave. I need to use a musical notation that is not.

I started to google on the subject but there are too many choices.

Does anyone have a suggestion about which notation to use. Simple would be good.
 
That'd depend on the actual library you're using. Where is playNote() defined and what is the code? Is there any documentation?

I'd be tempted to try 'C1' to get C above middle C, if I had no docs/comments to work from.


Torben

[Edit: What is the software you're using? i.e. the code library containing 'playNote()'? Without that info, we can only guess at what the programmer has decided would be a good octave encoding. With the name, we could maybe look it up.]

[Edit 2: Um. I've assumed you're using C. Is this true? If so, what does the .h file look like?]
 
Last edited:
No library. It is a program I am writting. I am not having a problem with the code. I do need some guidance on what the musical notation to pick.


FWIW:
This is not finished or polished code.
playNote is a big switch statement that calls aNote which is

Code:
void aNote(int duration,  
            long period)  // half the actual period of the note
{
  int i; 
  unsigned long _duration = tempo * duration;
  
  OpenTimer0( TIMER_INT_OFF &  T0_16BIT &  T0_SOURCE_INT & T0_PS_1_256 );
  WriteTimer0(0);
  
  while (((unsigned long) ReadTimer0()) < _duration )
  {       
            LATCbits.LATC3 = 0;
          delay_us(period); 
          LATCbits.LATC3 = 1;
          delay_us(period);
  }  

  CloseTimer0();
}
 
No problem. I realized I'm rusty at music notation and also found this: **broken link removed**

May be a bit more succinct. Anyway, sounds like a cool project.


Torben
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top