# Balena Audio Block Custom PA Script

**URL:** <https://forums.balena.io/t/balena-audio-block-custom-pa-script/359053>\
**Category:** Product support\
**Tags:** audio\
**Created:** [June 16, 2022, 9:27am UTC](https://forums.balena.io/t/balena-audio-block-custom-pa-script/359053 "2022-06-16T09:27:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukasknk](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@lukasknk](https://forums.balena.io/u/lukasknk)\
**Post date:** [June 16, 2022, 9:27am UTC](https://forums.balena.io/t/balena-audio-block-custom-pa-script/359053/1 "2022-06-16T09:27:04Z")

</div>

Hello

In order to properly use the Balena Audio block and actually output sound via my chosen Output i need to be able to set the following in a custom.pa script.

```auto
set-card-profile 0 output:hdmi-stereo

```

I found this to work by cloning the audio block and adding this as suggested in the documentation to the start cmd:

```auto
COPY custom.pa /usr/src/custom.pa
CMD ["pulseaudio", "--file /usr/src/custom.pa"]

```

My problem is now that i don’t know how to add a custom.pa file to a balena block. Currently i have cloned the audio balena block manually and added this inside that block code. This works perfectly fine but isn’t really the solution i’m looking for because it means that i need to have a local copy of the block and can therefore not profit from the advantages of a balena block.

Can someone help me with adding a custom pulse audio script to the balena audio block?

Thanks.

---

<div class="post-metadata">

**Author:** ![ramirogm](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@ramirogm](https://forums.balena.io/u/ramirogm)\
**Post date:** [June 16, 2022, 2:13pm UTC](https://forums.balena.io/t/balena-audio-block-custom-pa-script/359053/3 "2022-06-16T14:13:15Z")

</div>

Hi lukasknk

It sounds like you’ve managed to adapt the balena block to your needs by using a custom script, and now you’d like to reuse this block. What you can do is publish your custom version ( fork ) of the balena audio block as your own block. You can keep this new block private or make it public.

The overall steps are described in [Develop with blocks - Balena Documentation](https://www.balena.io/docs/learn/develop/blocks/#creating-your-own-block)

I’ve done them based on what you describe on my own, so you can use this as a reference.

First I forked the balena audio GitHub repo into my own org: [GitHub - ramirogm/audio: Audio building block for balenaOS, based on pulseaudio.](https://github.com/ramirogm/audio)

I then added your `custom.pa` script and edited the `Dockerfile` file, committed and pushed the changes.

The next step is to publish the changes. I went to my balena cloud dashboard and selected blocks on the left, created a new block, selected it, went to the “releases” page, and added a new one. This will show you that you need to run the following commands:

```auto
balena login
 balena push ramiro_gonzalez/audio

```

( obvs using your own organization )

If all goes well, you should see a happy unicorn at the end of the building process, and a new “release” on the block’s releases page on the dashboard.

You can then use this block on your docker-compose file using the “image reference” shown on the block Summary page. In my case, it’s `bh.cr/ramiro_gonzalez/audio`

Last step: I made the block public as explained in [Develop with blocks - Balena Documentation](https://www.balena.io/docs/learn/develop/blocks/#making-your-block-public)

Let me know if this helps!

Ramiro

---

<div class="post-metadata">

**Author:** ![ramirogm](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@ramirogm](https://forums.balena.io/u/ramirogm)\
**Post date:** [June 16, 2022, 2:25pm UTC](https://forums.balena.io/t/balena-audio-block-custom-pa-script/359053/9 "2022-06-16T14:25:05Z")

</div>

Here are some screenshots of the steps described above:

Create a block:

 ![01-create block](https://global.discourse-cdn.com/balena/original/2X/5/5069cf326436920602e9a2fc6bb3992de2b615e2.png)

Block properties:

 ![02-create block form](https://global.discourse-cdn.com/balena/original/2X/9/97fb860b9546521d8bc1d38be5d785fe95fbf49c.jpeg)

Adding a release

 ![03-add release](https://global.discourse-cdn.com/balena/original/2X/4/4079f56ce04d269a7ff152907c2ca200f4af7df5.jpeg)

The release is building after executing `balena push`

 ![04-release building](https://global.discourse-cdn.com/balena/original/2X/4/4da0023e2d4720c62acddd521bc2595d788784e2.jpeg)

---

<div class="post-metadata">

**Author:** ![lukasknk](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@lukasknk](https://forums.balena.io/u/lukasknk)\
**Post date:** [June 16, 2022, 4:46pm UTC](https://forums.balena.io/t/balena-audio-block-custom-pa-script/359053/11 "2022-06-16T16:46:47Z")

</div>

Thanks for that.

It wasn’t clear to me that the only way to adjust these things was to create a custom block. But that is good to know. Thanks for your help, this seemed to have been the solution i’m looking for.

---

<div class="post-metadata">

**Author:** ![ramirogm](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@ramirogm](https://forums.balena.io/u/ramirogm)\
**Post date:** [June 17, 2022, 1:06pm UTC](https://forums.balena.io/t/balena-audio-block-custom-pa-script/359053/12 "2022-06-17T13:06:39Z")

</div>

Hi  
Glad it helped! Let me know how it goes  
Ramiro

---

<div class="post-metadata">

**Author:** ![lukasknk](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@lukasknk](https://forums.balena.io/u/lukasknk)\
**Post date:** [June 17, 2022, 9:08pm UTC](https://forums.balena.io/t/balena-audio-block-custom-pa-script/359053/14 "2022-06-17T21:08:12Z")

</div>

Worked perfectly, thanks for your support.
