Skip to content

Sound effects system Part 1: Assets, Stereo sound - #3281

Closed
RanPix wants to merge 59 commits into
PixelGuys:masterfrom
RanPix:esefeks
Closed

RanPix wants to merge 59 commits into
PixelGuys:masterfrom
RanPix:esefeks

Conversation

@RanPix

@RanPix RanPix commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

requires #3367

this is mostly intended to be a base for other people to maybe continue on this

has a bit of renaming and test code, i still have to figure out what we will need

the questions i have for now:

  • do we want to be able to change the position of sounds? that would require creating some sort of audio soruce with a handle to a current playing sound which could allow for some cool things like a moving breathing of some scary monster
  • how would/should we integrate the sound system with music later?
  • in future, do we want to have dynamically changable special effects like pitch, reverb or distortion? so that for example when you break the same block all the time it has some pitch variation to make it less repetative

and i also would want to discuss how the ideal api for that would look like, and maybe what tools do we give to the artists

todo:

  • doppler effect - separate pr
  • simd sound mixing? - separate pr probably
  • playing sounds limit - separate pr
  • volume control based on how many of the same sounds are playing at the same time? - separate pr
  • find other optimizations
  • sound zon files should be able to specify the sound file they are using so we can reuse sounds in some cases? (could also be a separate pr if we need that)
  • dont process sounds that are too far / too silent
  • fix sounds sounding wrong
  • fix windows ikabod sound issue

@RanPix

RanPix commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

also for now you can tp to 0 0 0 to hear a testing sound thats constantly playing for stereo

@Wunka

Wunka commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

CI failed but I also don't understand if this is supposed to be reviewed?

@Wunka Wunka moved this to WIP/not ready for review in PRs to review Jul 5, 2026
@ikabod-kee

Copy link
Copy Markdown
Collaborator

@RanPix

RanPix commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

I bring you good news https://github.com/user-attachments/assets/e149d0c6-7759-4813-b974-33923733dc0e

YEEEEEEESSSSSSSSSSS, thank god its just a file issue

@RanPix

RanPix commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

ready for review

@ikabod-kee ikabod-kee moved this from WIP/not ready for review to Easy to Review in PRs to review Jul 19, 2026
@Crepestrom

Copy link
Copy Markdown
Contributor

finally we can have sound effects
thanks for that

IntegratedQuantum pushed a commit that referenced this pull request Jul 19, 2026
preparation for #3281 to reduce line count
@Crepestrom

Copy link
Copy Markdown
Contributor

are music and sound effects seperated?
so that you can turn down sound effects while having music be loud

@RanPix

RanPix commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

are music and sound effects seperated? so that you can turn down sound effects while having music be loud

yes, look at the settings for audio

@Crepestrom

Copy link
Copy Markdown
Contributor

ah good

@Crepestrom

Copy link
Copy Markdown
Contributor

can you add a field along with volume that slightly randomizes the pitch/playback speed of the sound effect
or will that be a seperate pr
this helps with making sounds less repetitive

@RanPix

RanPix commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

can you add a field along with volume that slightly randomizes the pitch/playback speed of the sound effect
or will that be a seperate pr
this helps with making sounds less repetitive

i tried implementing this several times and all of them were horrible, this will be a separate pr

@RanPix

RanPix commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

refer to this on sound effect system features #3364

Comment thread src/gui/windows/audio.zig
Comment thread src/assets.zig

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sound effects should be in https://github.com/PixelGuys/Cubyz-Assets/ together with the music

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PixelGuys/Cubyz-Assets#39
i have a pr for it im just waiting for it to get added before i can add that functionality

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it's waiting for artistic review

Comment thread src/audio.zig
Comment thread src/audio.zig
Comment thread src/audio.zig
const audioData = audios.items[sound.audioIndex];
const soundBuffer = audioData.data;

const notMonoInt: u32 = @intFromBool(audioData.channelType != .mono);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we forbid stereo tracks entirely? Ideally enforced through the conversion script in Cubyz-Assets.

@RanPix RanPix Jul 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ikabod-kee do we want stereo sounds? (not the directional spatial stuff in the game but the audio itself being stereo), having no stereo sounds would make things simplier

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setro tracks are just interpereted as mono with the first channel only being read

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't just blindly reinterpret stuff, log an error instead and discard the track.
It's potentially losing data and wasting performance, so I think we shouldn't allow it in the first place.
It's easy to reformat tracks as mono with any audio editor.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok throws a error and returns a null now

Comment thread src/audio.zig
@IntegratedQuantum IntegratedQuantum moved this from Easy to Review to In review in PRs to review Jul 25, 2026
@Crepestrom

Copy link
Copy Markdown
Contributor

is this still being worked on?

@RanPix

RanPix commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

is this still being worked on?

at the moment no, but you can overtake this pr if you are willing to finish it

@Crepestrom

Copy link
Copy Markdown
Contributor

I am bored and willing to contribute

@Crepestrom

Copy link
Copy Markdown
Contributor

good job making this pr

@RanPix RanPix removed this from PRs to review Sep 23, 2026
@RanPix RanPix closed this Sep 23, 2026
@RanPix

RanPix commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

moved to #3626

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants