Error

I am running my tunes thing but when I get to the rest, I get an error

case "h"://this is when my code reads an h. it adds a rest to the melody
                        melody.Add(Tunes.Tone.Rest, a);//a is a duration. it is set to 200
                        break;
                }

            }                      

           
            tunes.Play(melody);//then here it plays everything that was added

just a snippet. Is the rest note broken? Every note plays up until this one. Attached is screenshot of error

you got a PWM exception. So whatever was in your tune was causing an issue in PWM, most likely because it incorrectly set a PWM value that the PWM handler in netmf couldn’t recognise. You need to understand what note it was playing to really understand this, I suspect…

maybe Ppause rather than Rest?

@ suitable1 - There is only Tunes.Tone.Rest
Theres no pause in there.

This code reproduces the error:

void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
            Tunes.Melody m = new Tunes.Melody();
            m.Add(Tunes.Tone.Rest, 200);
            tunes.Play(m);
        }

Is Rest defined as zero frequency?

@ suitable1 - I think it is, because its assigning a pwm frequency. im sure a 0 frequency would make an error

@ MRTFEREN - If you start a new project and just call tunes.Play(Tunes.Tone.Reset, 1000), does it give the error still? What board are you using?

@ John - That’s invalid code. id need to do do this


and it gives error.

Cerbuino Bee

@ MRTFEREN - Should be fixed for the next SDK. You can find the fix in the latest source at https://bitbucket.org/ghi_elect/gadgeteer/src/acea1771fbf0e77df651abd283bc3bca1e5e6082/Modules/GHIElectronics/Tunes/Tunes_43/Tunes_43.cs?at=master

https://www.ghielectronics.com/docs/122/gadgeteer-driver-modification will help you to use it.