> ## Documentation Index
> Fetch the complete documentation index at: https://kawax.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# Native modus: song (zangsynthese) - VOICEVOX for Laravel

> Uitleg over zangsynthese in de native modus van VOICEVOX for Laravel door VOICEVOX CORE rechtstreeks via PHP FFI aan te roepen.

## Laten zingen in de native modus

Bij zangsynthese in de native modus roep je VOICEVOX CORE rechtstreeks aan via PHP FFI.

Het opbouwen van `Score` en `Note` is hetzelfde als in de clientmodus.

## Voorbereiding

1. Je hebt [Installatie en configuratie](https://kawax.biz/nl/packages/laravel-voicevox/installation.md) afgerond
2. Je hebt [VOICEVOX Core for PHP](https://kawax.biz/nl/packages/voicevox-core-php.md) opgezet
3. Je hebt `VOICEVOX_CORE_PATH` ingesteld in `.env`

```dotenv theme={null}
VOICEVOX_CORE_PATH=/path/to/voicevox_core/
```

Om zangmodellen te gebruiken, controleer je of `s0.vvm` is opgenomen in `core.vvms` in `config/voicevox.php`.

## Een `Score` en `Note` maken

```php theme={null}
use Revolution\Voicevox\Song\Note;
use Revolution\Voicevox\Song\Score;

$score = Score::make([
    Note::make(length: 15),
    Note::make(length: Note::len(ticks: 480, bpm: 120), lyric: 'ド', key: 60),
    Note::make(length: Note::len(480, 120), lyric: 'レ', key: 62),
    Note::make(length: Note::len(960, 120), lyric: 'ミ', key: 64),
    Note::make(length: 2),
]);
```

## Basisgebruik

```php theme={null}
use Revolution\Voicevox\Song\Note;
use Revolution\Voicevox\Song\Score;
use function Revolution\Voicevox\song;

$score = Score::make([
    Note::make(length: 15),
    Note::make(length: Note::len(480, 120), lyric: 'ド', key: 60),
    Note::make(length: Note::len(480, 120), lyric: 'レ', key: 62),
    Note::make(length: Note::len(960, 120), lyric: 'ミ', key: 64),
    Note::make(length: 2),
]);

$response = song($score, teacher: 6000)
    ->generate(id: 3001);

$response->storeAs('native', 'song.wav');
```

Als je dezelfde `Score` gebruikt, kun je één gedeelde partituur hergebruiken in zowel de clientmodus als de native modus.

## F0 en volume opnieuw synchroniseren met `tap()`

Ook bij native Song is `tap()` nuttig. Na het aanpassen van de `SongAudioQuery` kun je die direct doorgeven aan `generate()`.

```php theme={null}
use Revolution\Voicevox\Song\SongAudioQuery;
use function Revolution\Voicevox\song;

$response = song($score, teacher: 6000)
    ->tap(function (SongAudioQuery $song) {
        $song->sync();
    })
    ->generate(id: 3001);
```

Als je F0 en volume afzonderlijk bijwerkt, voer je ze altijd in deze volgorde uit.

```php theme={null}
->tap(function (SongAudioQuery $song) {
    $song->updateF0();
    $song->updateVolume();
})
```

## Verschillen met de clientmodus

| Onderdeel | Client Song | Native Song |
| - | - | - |
| Engine starten | Nodig | Niet nodig |
| FFI | Niet nodig | Nodig |
| API-ingang | `Voicevox::song()` | `song()` |
| `Score` / `Note` | Gedeeld | Gedeeld |

> [!NOTE]
>
> Hoe FFI werkt lees je in [PHP FFI](https://kawax.biz/nl/advanced/ffi.md); de flow van alleen de corebibliotheek vind je in [VOICEVOX Core for PHP gebruiken](https://kawax.biz/nl/packages/voicevox-core-php/usage.md).

## Volgende pagina's

> [card] [Score en Note in detail](https://kawax.biz/nl/packages/laravel-voicevox/song-score-note.md)
>
> Bekijk praktische manieren om Song-partituurgegevens te beheren.

> [card] [Client Song](https://kawax.biz/nl/packages/laravel-voicevox/client-song.md)
>
> Vergelijk de verschillen met de HTTP-clientversie.

> [card] [Overzicht van VOICEVOX for Laravel](https://kawax.biz/nl/packages/laravel-voicevox.md)
>
> Bekijk alle modi en gerelateerde pagina's in één overzicht.


## Related topics

- [Clientmodus: song (zangsynthese) - VOICEVOX for Laravel](https://kawax.biz/nl/packages/laravel-voicevox/client-song.md)
- [Engine-API-modus: song (zangsynthese) - VOICEVOX for Laravel](https://kawax.biz/nl/packages/laravel-voicevox/engine-song.md)
- [Native modus: talk (tekst-naar-spraak) - VOICEVOX for Laravel](https://kawax.biz/nl/packages/laravel-voicevox/native-talk.md)
- [Native modus - presets - VOICEVOX for Laravel](https://kawax.biz/nl/packages/laravel-voicevox/native-presets.md)
- [Native modus - gebruikerswoordenboek - VOICEVOX for Laravel](https://kawax.biz/nl/packages/laravel-voicevox/native-user-dict.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.