Skip to content

Prevention of short audible clicks when switching between stations #122

@Frank-Bemelman

Description

@Frank-Bemelman

My usual approach to switch between stations, was to first set the volume to zero, then a stopSong, connect to the new url, and if the new stream is running, set the volume back to the normal level. Something like this:

  stream.setVolume(0);
  if(stream.isRunning())
  { stream.stopSong();
  }
 
  stream.connectToHost(TargetUrl);  

  if(stream.isRunning()) 
  { stream.setVolume(volumevalue); // restore volume
  }

This method, more often than not, gives audible clicks or odd (short) snippets of unwanted sound. I tried various 'solutions' such as adding delays before turning up the volume again, using fading volume slowly up, all not very elegant or 100% fixing the problem.

But now I found a new method. Instead of restoring the volume after a plain connect, wait for the codec callback, and let that handle the volume restore.

// Called when codec is detected
void codecCallBack(const char *codec)
{ Serial.printf("codec: %s\n", codec);
  stream.setVolume(volumevalue); // restore volume
}

Thought let's share this idea, for me this works very satisfying. No clicks, no odd snippets, just a smooth switch.

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