Stop/Start melody using buttons and pitches.h

How do you start/stop/reset the melody of pitches.h using buttons. For instance the button 1 will start/stop the melody and button 2 will reset the melody. Am I going to use if else?

#include pitches.h
void setup() {
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  
  }
}

void loop() {
  b1 = digitalRead(2);
  b2 = digitalRead(3);

 
}

void function(int pin, int sw) {

}

How do you start/stop/reset the melody of pitches.h using buttons.

The pitches.h file simply defines some frequencies with some usable names.

So, it is irrelevant to what you want to do.

You need to define HOW the switches are wired.

The state change detection example shows how to determine that a switch HAS BECOME pressed (or has become released). That is what you should start with.

Starting something happening when a switch has become pressed is easy.
Stopping that when another switch has become pressed is easy.

In both cases, you change the state of a boolean variable. Say you have one called needToPlay. When the start switch becomes pressed, set needToPlay to true. When the stop switch becomes pressed, set needToPlay to false.

Independently of the switches, if needToPlay is true, play the music.

That means keeping track of where you are in the song, and determining if it is time to start the next note playing. The blink without delay example will provide a lot of clues about how to do that.