MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / source_stft_bct

Function source_stft_bct

src/framework/modules/hift_vocoder.cpp:483–513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481}
482
483std::vector<float> source_stft_bct(
484 const HiftVocoderWeights & weights,
485 const std::vector<float> & source,
486 int64_t & stft_frames,
487 std::vector<float> & window) {
488 const audio::STFTConfig window_config{
489 weights.config.istft_n_fft,
490 weights.config.istft_hop,
491 weights.config.istft_n_fft,
492 true,
493 audio::STFTPadMode::Reflect,
494 audio::STFTFamily::Kokoro,
495 };
496 window = audio::get_cached_stft_window(window_config);
497 const auto complex = audio::STFT().compute_complex(
498 source,
499 window,
500 1,
501 static_cast<int64_t>(source.size()),
502 {weights.config.istft_n_fft, weights.config.istft_hop, weights.config.istft_n_fft});
503 stft_frames = complex.shape[2];
504 std::vector<float> stft(static_cast<size_t>(kHiftStftChannels * stft_frames), 0.0F);
505 for (int64_t f = 0; f < kHiftStftBins; ++f) {
506 for (int64_t t = 0; t < stft_frames; ++t) {
507 const size_t complex_index = static_cast<size_t>((f * stft_frames + t) * 2);
508 stft[static_cast<size_t>(f * stft_frames + t)] = complex.values[complex_index];
509 stft[static_cast<size_t>((kHiftStftBins + f) * stft_frames + t)] = complex.values[complex_index + 1];
510 }
511 }
512 return stft;
513}
514
515std::vector<float> waveform_from_post(
516 const HiftVocoderWeights & weights,

Callers 1

runMethod · 0.85

Calls 3

STFTClass · 0.85
compute_complexMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected