Skip to content

unpleasent noises at the end of songs #4

@JacquesDuflos

Description

@JacquesDuflos

Hi,
I have copied your code (actually I have simplified it a little) and I have had an issue : the last note of the songs was not played and i had a dreadfull noise during few seconds (like when you call a fax with an old fashion phone). I think I get the answer :
The lines for in the songs functions are wrong : you use sizeof to find the size of the array, but it does not give you the number of elements, but the size (in bite) of the object. I made the following correction and it nearly work (it does not play the last note for some reason) :
`

  int sariaSongArray[] = {_F4, _A4, _B4, _F4, _A4, _B4, _F4, _A4, _B4, _E5, _D5, _B4, _C5, _B4, _G4, _E4, _D4, _E4, _G4};
  int sariaSongDelay[] = {250, 250, 500, 250, 250, 500, 250, 250, 250, 250, 500, 250, 250, 250, 250, 625, 250, 250, 250};

  int sariaSongSize = sizeof(sariaSongArray)/sizeof(sariaSongArray[0]);

  for(int i = 0;i < sariaSongSize;i++){

      tone(speakerPin, sariaSongArray[i]);

      delay(sariaSongDelay[i]);
  }

`

Hope I helped

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions