# Sounds and music (/ink/sound)





The ***ink* + Pixi’VN integration** introduces a "# script" that allows you to use the <DynamicLink href="/start/sound">sounds and music</DynamicLink>. To do this, you need to use the following syntax:

```ink title="ink"
# {operation} {component type} {alias} {parameters}
```

* `#`: is the hashtag symbol to identify a hashtag command.
* `operation`: the operation to perform. Currently supported:
  * `play`: Play a sound. (Read more [here](#play))
  * `pause`: Pause a sound. (Read more [here](#pause-and-resume))
  * `resume`: Resume a sound. (Read more [here](#pause-and-resume))
  * `stop`: Stop a sound. (Read more [here](#stop))
  * `edit`: Edit a sound. (Read more [here](#edit))
* `component type`: the component type. Available types:
  * `sound`: to play, pause, resume, stop or edit a sound.
  * `channel`: to run an operation on a channel.
* `alias`: The alias to identify the sound. Use double quotes if the alias contains spaces.
* `parameters&#x60; (Optional): a space-separated list of property/value pairs. If a value contains spaces, wrap it in double quotes. If a value is a object, pass valid JSON and escape the braces for &#x2A;**ink*** (e.g. `\{ "placeholder": "Enter your name", "maxLength": 20 \}`).

<CodeBlockTabs defaultValue="ink/start.ink">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="ink/start.ink">
      ink/start.ink
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="assets/manifest.ts">
      assets/manifest.ts
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="ink/start.ink">
    ```ink
    # play sound sfx_whoosh delay 0.1
    # play sound bgm_cheerful loop true channel bgm
    Hello, I'm a cheerful background music that will loop forever until you stop me.
    # pause sound bgm_cheerful
    I'm paused, but I can be resumed.
    # resume sound bgm_cheerful
    I'm back!
    ```
  </CodeBlockTab>

  <CodeBlockTab value="assets/manifest.ts">
    ```ts
    import { AssetsManifest } from "@drincs/pixi-vn";

    /**
     * Manifest for the assets used in the game.
     * You can read more about the manifest here: https://pixijs.com/8.x/guides/components/assets#loading-multiple-assets
     */
    const manifest: AssetsManifest = {
        bundles: [
            {
                name: "audio",
                assets: [
                    {
                        alias: "bgm_cheerful",
                        src: "https://raw.githubusercontent.com/DRincs-Productions/pixi-vn-bucket/refs/heads/main/audio/bgm_cheerful.wav",
                    },
                    {
                        alias: "sfx_whoosh",
                        src: "https://raw.githubusercontent.com/DRincs-Productions/pixi-vn-bucket/refs/heads/main/audio/sfx_whoosh.wav",
                    },
                ],
            },
        ],
    };
    export default manifest;
    ```
  </CodeBlockTab>
</CodeBlockTabs>

<SoundExample />

Play [#play]

You can use the `play` to <DynamicLink href="/start/sound#play">play</DynamicLink&#x3E; a sound in &#x2A;**ink***. To do this, you need to use the following syntax:

```ink title="ink"
# play sound {alias} {source} {parameters}
```

* `[parameters] (Optional)`: In the `parameters` you must include the properties of `SoundPlayOptions` that you want to set. The `parameters` must be set as follows: `parameterName` + `SPACE` + `value`. If the `value` is a string and includes spaces, you must use double quotes.

<CodeBlockTabs defaultValue="ink/start.ink">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="ink/start.ink">
      ink/start.ink
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="assets/manifest.ts">
      assets/manifest.ts
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="ink/start.ink">
    ```ink
    # play sound sfx_whoosh
    Now the sfx_whoosh is singing.
    # play sound sfx_whoosh volume 100
    Now the sfx_whoosh is singing louder.
    ```
  </CodeBlockTab>

  <CodeBlockTab value="assets/manifest.ts">
    ```ts
    import { AssetsManifest } from "@drincs/pixi-vn";

    /**
     * Manifest for the assets used in the game.
     * You can read more about the manifest here: https://pixijs.com/8.x/guides/components/assets#loading-multiple-assets
     */
    const manifest: AssetsManifest = {
        bundles: [
            {
                name: "audio",
                assets: [
                    {
                        alias: "bgm_cheerful",
                        src: "https://raw.githubusercontent.com/DRincs-Productions/pixi-vn-bucket/refs/heads/main/audio/bgm_cheerful.wav",
                    },
                    {
                        alias: "sfx_whoosh",
                        src: "https://raw.githubusercontent.com/DRincs-Productions/pixi-vn-bucket/refs/heads/main/audio/sfx_whoosh.wav",
                    },
                ],
            },
        ],
    };
    export default manifest;
    ```
  </CodeBlockTab>
</CodeBlockTabs>

Pause and resume [#pause-and-resume]

To <DynamicLink href="/start/sound#pause-and-resume">pause</DynamicLink&#x3E; a sound or a channel in &#x2A;**ink***, you can use the `pause` operation. To do this, you need to use the following syntax:

```ink title="ink"
# pause {component type} {alias}
```

To <DynamicLink href="/start/sound#pause-and-resume">resume</DynamicLink&#x3E; a sound or a channel in &#x2A;**ink***, you can use the `resume` operation. To do this, you need to use the following syntax:

```ink title="ink"
# resume {component type} {alias}
```

To pause or resume all sounds, you can use the following syntax:

```ink title="ink"
# pause all sounds
# resume all sounds
```

Edit [#edit]

To <DynamicLink href="/start/sound#edit">edit</DynamicLink&#x3E; a sound in &#x2A;**ink***, you can use the `edit` operation. To do this, you need to use the following syntax:

```ink title="ink"
# edit sound {alias} {parameters}
```

```ink title="ink"
# edit sound bgm_cheerful volume 50
# edit sound bgm_cheerful loop false
```

Stop [#stop]

To <DynamicLink href="/start/sound#stop">stop</DynamicLink&#x3E; a sound in &#x2A;**ink***, you can use the `stop` operation. To do this, you need to use the following syntax:

```ink title="ink"
# stop sound {alias}
```

```ink title="ink"
# stop sound bgm_cheerful
```

To stop all sounds, you can use the following syntax:

```ink title="ink"
# stop all sounds
```
