Page 1 of 1

Sound with Fun

Posted: 05 Nov 2017, 05:16
by KINGTUT10101
Would it be possible to make a building play a sound using fun?

Re: Sound with Fun

Posted: 05 Nov 2017, 05:19
by CommanderABab
That might get out of hand very quickly!

Re: Sound with Fun

Posted: 05 Nov 2017, 13:02
by Lobby
Sure, will be added:

Code: Select all

[
  {
    "id":"$fun_soundtest_sound00",
    "type":"sound",  // Type sound
    "file":"sound.mp3",  // Sound file in same directory
    "volume":1.0  // Default is 1.0
  },
  {
    "id":"$fun_soundtest_usage00",
    "type":"decoration",
    ...
    "on click fun":[
      {
        "actions":[
          {"type":"play","id":"$deco_soundtest_sound00"}  // Play sound
        ]
      }
    ]
  }
]

Re: Sound with Fun

Posted: 05 Nov 2017, 13:12
by TheFennekin
So the music file will come with your files? You are just gonna choose a music file? Disregard this dumb question

Re: Sound with Fun

Posted: 05 Nov 2017, 16:23
by KINGTUT10101
Yes. I was inspired by redstone and noteblocks from Minecraft.

Re: Sound with Fun

Posted: 06 Nov 2017, 01:42
by KINGTUT10101
Yes, but now we can do it with fun.

Re: Sound with Fun

Posted: 11 Nov 2017, 00:52
by KINGTUT10101
I've noticed that the pitch of a sound changes with every use. Could this be fixed @Lobby

Re: Sound with Fun

Posted: 11 Nov 2017, 00:59
by Lobby
Wow, you're good. I forgot about that... it's used to avoid that same samples sum up to a loud noise.

Re: Sound with Fun

Posted: 11 Nov 2017, 04:33
by KINGTUT10101
There's also a crackling sound that occurs sometimes

Re: Sound with Fun

Posted: 31 Mar 2019, 15:06
by Lobby
I think I have found a solution to the crackling sound issue.

But more importantly @ KINGTUT10101 I recently found out that it would be better to avoid ogg or wav files in your plugins completely since they may lead to playback issues dependent on how the manufacturer implemented it :teach
(Yes, as a programmer you normally you use pre-written functions and don't write things like that on your own, especially for complicated stuff like sound)

My conclusion is that MP3 is the only "safe" solution. It should also have similar file size compared to ogg while wave is basically unusable from a file size perspective. In case you have to convert files I can recommend a free tool called Audacity (for PC).
You have to use MP3 in order to support iOS.

Re: Sound with Fun

Posted: 31 Mar 2019, 17:35
by Imran M
Time to make a meme.

Re: Sound with Fun

Posted: 08 Jun 2019, 17:58
by Lobby
:66:
In order to support iOS you have to use MP3 since other music formats are not supported there.
Unsupported sound files will simply be ignored, so your plugins will still work, just without sound.

Re: Sound with Fun

Posted: 24 Nov 2020, 02:17
by THEMAX
Hey lobby, i wondered something.
Does the game support plugins which can have sounds effect just like roads (traffic sound), tree (chirping birds) when you are zooming ? Cause i thought about some commercial buildings for my plugin having that functionality to make cities feels more animated.

@Lobby

Re: Sound with Fun

Posted: 24 Nov 2020, 07:50
by JustAnyone
Use Lua for that

Re: Sound with Fun

Posted: 20 Mar 2022, 11:40
by TheFennekin
What is the max length of the sound can it play?