Smoothswings start when?

It could be cool to have smoothswing pairs and hum guaranteed to start in sync. Is this possible?
It seems the smoothswings are sort of either starting in a random place of their duration, or like the clock starts with boot maybe?

Currently, when we switch from one smoothswing pair to another, we take the position we were at in the previous pair, and start there in the new pair. Not a super-precise method, it’s just meant to allow you to use long swing pairs without hearing the beginning of the file over and over again.

If there isn’t a “previous” pair, then we start from the beginning

Synchronizing with the hum (or something else) wouldn’t be that hard I would think.

So the use case here is musical.
One smoothing pair, identical files so there’s no audible change while swinging around.
8 bars looping in the hum, 8 bars looping in swings, ( so identical durations )
However the start of hum at ProffieOSHumDelay=0 and the swings starting at the same zero is required to sync.
Where would I poke around for this?
Not clearly seeing why they wouldn’t start simultaneously looking in smooth_swing_v2.h

So, right now smoothswing ignores any humdelay thingies and starts the smoothswing pairs immediately when the blade is powered on. I suppose if you set the new ProffieOSHumDelay to 0, then they should start at the same time.

I don’t know if they will stay in sync though…

If I wanted to hack it up just to make it work, then I would change PickRandomSwing to use the hum player to get the position to start from, and if no hum player was available, just try again later. It might end up a few samples off, but that’s probably not a big deal.

sounds straight forward, but I’ve had no luck. My C foo is weak on pointers.

Well, it would be something like:

RefPtr<BufferdWavPlayer> humplayer = GetWavPlayerPlaying(hybrid_font.getHum());
if (!humplayer) return;
float start = humplayer->pos();

shoot. I had almost all that except GetWavPlayerPlaying(hybrid_font.getHum()

Well it works and makes this project perfect!
So to keep this, yet retain the “pick up where we left off” functionality for a new pair, something simple like this could work?

   void PickRandomSwing() {
    if (!on_) return;
    uint32_t m = millis();
    float start = m / 1000.0;
    RefPtr<BufferedWavPlayer> humplayer = GetWavPlayerPlaying(hybrid_font.getHum());
    if (!humplayer) return;
    if (first_start_) {
      start = humplayer->pos();
      first_start_ = false;

    bool first_start_ = true;

edit - oh…then they go out of sync after the first time finishes…i think.
Maybe a better way is to set the font config.ini to tell the OS this is a weird font that we want to sync Smoothswings to the hum :slight_smile:
Something like:

  void PickRandomSwing() {
    if (!on_) return;
    uint32_t m = millis();
    RefPtr<BufferedWavPlayer> humplayer = GetWavPlayerPlaying(hybrid_font.getHum());
    if (!humplayer) return;
    float start = (font_config.ProffieOSSmoothSwingHumstart == 0) ? m / 1000.0 : humplayer->pos();


    CONFIG_VARIABLE2(ProffieOSSmoothSwingHumstart, 0);
  // Make smoothswings start in sync with hum.
  // Set to 1 to sync, or 0 to resume swings where last pair left off.
  bool ProffieOSSmoothSwingHumstart;

I’m not sure what you are trying to do here.
IMHO, it’s best to just NOT start the swing pairs until there is a hum to synchronize it with. That’s why I put a return in there.

It may be that you need to add some code elsewhere to call PickRandomSwing() more often if the swing pairs haven’t started yet though.

A font config variable could certainly work here, assuming that this is a feature that more people than you want.

This was thinking that just the first start of playback would need to sync with hum to fit this special use of pairs, yet not disturb the normal way of working for swing pairs that are typical once new pairs are chosen as we go along.
The font config option is working at the moment.

1 Like