Help decoding waveform data from Vital presets?

Could anyone on the Vital team (or power users in the know) provide some insight into the encoding methods used for the samples and wave_data values in the presets?

I am building an AI model to design sounds based on user input, but am blocked by this step. After knowing the encoding method I can build a data pipeline to allow users to describe the sounds they want in natural language, and have that sound generated as a Vital preset. Any help would be appreciated!

Attached: Example of encoded wave_data

I’ve been trying to figure this out for a while though, no luck though. It’s probably somewhere in the source code, but I’m not c++ savy enough to find it and Vital has no documentation at all.
I’m guessing it’s a audio file without all the extra metadata and just the audio content, but I haven’t put in the effort of figuring out how to extract that into a useable format.
Good luck in your search!

The code shows this:
Base64::convertFromBase64

1 Like

Sweet, thanks!

For anyone else with the same question that stumbles upon this, here is an example of where the wavetable data is encoded:

json WaveSourceKeyframe::stateToJson() {
  String encoded = Base64::toBase64(wave_frame_->time_domain, sizeof(float) * vital::WaveFrame::kWaveformSize);
  json data = WavetableKeyframe::stateToJson();
  data["wave_data"] = encoded.toStdString();
  return data;
}

and here is an example of it being decoded:

void WaveSourceKeyframe::jsonToState(json data) {
  WavetableKeyframe::jsonToState(data);

  MemoryOutputStream decoded(sizeof(float) * vital::WaveFrame::kWaveformSize);
  std::string wave_data = data["wave_data"];
  Base64::convertFromBase64(decoded, wave_data);
  memcpy(wave_frame_->time_domain, decoded.getData(), sizeof(float) * vital::WaveFrame::kWaveformSize);
  wave_frame_->toFrequencyDomain();
}

toBase64 and convertFromBase64 are from the JUCE 5 module.

1 Like