# Variable humstart tie in to WavLen?

**URL:** <https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313>\
**Category:** Sound Fonts\
**Created:** [April 29, 2021, 1:55am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313 "2021-04-29T01:55:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [April 29, 2021, 1:55am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/1 "2021-04-29T01:55:24Z")

</div>

Now that WavLen is becoming a thing, would it be difficult to tie in the humstart code to calculate ~80% of the out.wav and always be correct?

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [April 29, 2021, 2:52am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/2 "2021-04-29T02:52:58Z")

</div>

I suppose, why?

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [April 29, 2021, 3:10am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/3 "2021-04-29T03:10:47Z")

</div>

If humstart is set to 1000 and any of the the out.wavs are longer than 1200-1500ms, it’s pretty audible.  
If the out.wav is 500, hum is instant.  
Just thought it might make sense to have it automatically always start just about 20% into out.wav playing.  
Custom settings could still be used. Such as humstart 1500, but also maybe a setting of humstart AUTO ?

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [April 29, 2021, 3:32am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/4 "2021-04-29T03:32:27Z")

</div>

The _current_ way to fix this is to extend short out.wav files with silence until the hum starts at the right spot. (Which is usually the crescendo of the out.wav file.) So in you want the hum to start at 100ms, humstart is 1000 and out.wav is 500ms, then you need to extend that file with 600ms of silence.

I wouldn’t mind having a better way to do this, but no hard-coded number ever going to be right for every situation.

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [April 29, 2021, 3:37am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/5 "2021-04-29T03:37:07Z")

</div>

> [@profezzorn](#):
>
> , but no hard-coded number ever going to be right for every situation.

That’s exactly what I was saying. Maybe have an auto option that could have the humstart get the time from the out.wav length, and subtract 20%ish.

The adding silence solution works when out is too short, yes, but the case is usually the opposite, where the out contains long audio.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [April 29, 2021, 3:38am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/6 "2021-04-29T03:38:48Z")

</div>

> [@NoSloppy](#):
>
> The adding silence solution works when out is too short, yes, but the case is usually the opposite, where the out contains long audio.

Then you increase humstart and extend the _other_ wav files.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [April 29, 2021, 3:40am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/7 "2021-04-29T03:40:38Z")

</div>

I actually think that the monophonic way of doing the ignition-\>hum transition is better as it gives the font maker total control over the transition.

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [April 29, 2021, 3:44am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/8 "2021-04-29T03:44:41Z")

</div>

While that’s true, I think it’s too late to ever see a retroactive revamp of all the poly fonts produced thus far.  
If I wanted to tinker, hybrid\_font.h around lines 330ish the right place?  
Look up some WavLen stuff from the master?

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [April 29, 2021, 3:51am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/9 "2021-04-29T03:51:33Z")

</div>

Yep, that’s the right place. Specifically:

> <https://github.com/profezzorn/ProffieOS/blob/5dfdce1604ec7398006d6ada539a542e245bb35b/sound/hybrid_font.h#L335>

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [April 29, 2021, 7:03am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/10 "2021-04-29T07:03:35Z")

</div>

well, this doesn’t work so far.

```auto
     else {
  #ifdef AUTO_HUMSTART
            hum_start_ = (1000 * tmp->length() - (tmp->length() * (100/40)));
      STDOUT << "humstart: Auto timed to out.wav\n";
  #else
        if (font_config.humStart && tmp) {
          int delay_ms = 1000 * tmp->length() - font_config.humStart;
          if (delay_ms > 0 && delay_ms < 30000) {
            hum_start_ += delay_ms;
          }
      STDOUT << "humstart: " << font_config.humStart << "\n";
        }        
  #endif // AUTO_HUMSTART
      }

```

I don’t understand the 1000 \*  
Something to do with integer division?  
Guessing a bit that tmp is the wav’s length.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [April 29, 2021, 7:12am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/11 "2021-04-29T07:12:11Z")

</div>

The 1000 is just converting seconds to milliseconds.  
tmp-\>length() is the length of the chosen out\*.wav in seconds.

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [April 29, 2021, 7:45am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/12 "2021-04-29T07:45:45Z")

</div>

I must be missing something. I thought maybe just my math was off, but even with this test where I just manually set hum\_start\_ to 200, I keep getting hum immediately played.

```auto
      else {
  #ifdef AUTO_HUMSTART
            hum_start_ = 200;
            //hum_start_ = 1000 * tmp->length() - (1000 * tmp->length() * (10/40));
      STDOUT << "humstart: " << hum_start_ << "\n";
  #else
        if (font_config.humStart && tmp) {
          int delay_ms = 1000 * tmp->length() - font_config.humStart;
          if (delay_ms > 0 && delay_ms < 30000) {
            hum_start_ += delay_ms;
          }
      STDOUT << "humstart: " << font_config.humStart << "\n";
        }        
  #endif // AUTO_HUMSTART
      }

```

Serial monitor does output humstart: 200. Trying 2000 as it seems hum\_start is the opposite of font.config.humstart…  
Nope. It seems it’s not being recognized, which seems weird since the stock code is just setting hum\_start\_ which is how long to wait to play hum.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [April 29, 2021, 8:05am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/13 "2021-04-29T08:05:48Z")

</div>

Actually, what it does is to _add_ to hum\_start\_.  
A few lines earlier it sets hum\_start\_ to millis()

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [April 29, 2021, 8:09am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/14 "2021-04-29T08:09:20Z")

</div>

Yes, that’s what I saw, it’s the opposite, so when trying 2000, I expected a 2 second delay for hum. It still played the same as 200, immediately with the out.wav as if it’s not reading hum\_start\_.  
Looking at this, I’m wondering the reason why this does the steps it does.  
Couldn’t it be simpler to have just have the config.ini file’s humstart value directly be the delay\_ms? Leaving in the check sthat it exists and is between 1 and 30000ms, couldn’t it just be:

```auto
if (font_config.humStart) {
    if (font_config.humStart > 0 && delay_ms < 30000) {
    hum_start_ = font_config.humStart;
    }
}

```

And is the default 100 the fall through if all this is false?

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [April 29, 2021, 8:13am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/15 "2021-04-29T08:13:12Z")

</div>

Maybe that’s accounting for a monophonic font. Hmm I still don’t see why just setting a value doesn’t change anything. Still playing hum with zero delay.

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [April 29, 2021, 8:30am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/16 "2021-04-29T08:30:14Z")

</div>

hum\_start\_ is a _time_ not a _delay_.  
The unit is in milliseconds since boot.  
That’s why it has to have millis() added to it, which is the current time.  
When you set it to 200 or 2000, it means “start the hum at 2000 milliseconds after boot”, which was probably a long time ago.

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [April 29, 2021, 8:31am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/17 "2021-04-29T08:31:12Z")

</div>

Yes…I was typing.  
The system clock time is running since power on. I get it.  
They delay isn’t accounting for all the time that’s passed since power applied.  
Now my math is just bad I’m getting humstart: 454396 sort of output

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [April 29, 2021, 8:34am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/18 "2021-04-29T08:34:20Z")

</div>

Might be reasonable if you booted ~7 minutes ago.

---

<div class="post-metadata">

**Author:** ![NoSloppy](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/nosloppy/32/3865_2.png) [@NoSloppy](https://crucible.hubbe.net/u/NoSloppy)\
**Post date:** [April 29, 2021, 8:52am UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/19 "2021-04-29T08:52:54Z")

</div>

Ok I got it. Working well!

```auto
      else {
  #ifdef AUTO_HUMSTART
      int delay_ms = 1000 * tmp->length() * 25 / 100 ;
      hum_start_ += delay_ms;
      STDOUT << "humstart: " << delay_ms << "\n";
  #else
        if (font_config.humStart && tmp) {
          int delay_ms = 1000 * tmp->length() - font_config.humStart;
          if (delay_ms > 0 && delay_ms < 30000) {
            hum_start_ += delay_ms;
          }
      STDOUT << "humstart: " << font_config.humStart << "\n";
        }        
  #endif // AUTO_HUMSTART
      }

```

---

<div class="post-metadata">

**Author:** ![profezzorn](https://crucible.hubbe.net/user_avatar/crucible.hubbe.net/profezzorn/32/8_2.png) [@profezzorn](https://crucible.hubbe.net/u/profezzorn)\
**Post date:** [April 29, 2021, 5:29pm UTC](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313/20 "2021-04-29T17:29:12Z")

</div>

I suppose we could have both a percentage and an offset. So instead of:

delay = wavLength - humStart

We could do:

delay = wavLength \* humStartPercent / 100 - humStart

humStartPercent would default to 100.  
It also means that you could set humStartPercent to 0 and humStart to -200 if you always want the hum to start 200ms after the ignition.

[Next page](https://crucible.hubbe.net/t/variable-humstart-tie-in-to-wavlen/313.md?page=2)
