few sound questions - SOLVED

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

few sound questions - SOLVED

Post by Drakkan »

1. Somebody has some tips what is the best supported format for files in direction of size (I do not care about quality). Curently I am using waw PCM signed 16 bit, mono and like 1 sec has 100kb. is there some lower supported solution ?
answered by minmay


2. can I somehow re-play some defined sound twice / three time etc. ? following is not working.
resolved - thanks to Aisuu
SpoilerShow

Code: Select all

function ring()
playSound("bell")
delayedCall("myskript",5,"ring2") 
end

function ring2()
playSound("bell")
end
Last edited by Drakkan on Thu Jan 15, 2015 12:48 am, edited 4 times in total.
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Aisuu
Posts: 61
Joined: Fri Oct 31, 2014 2:07 pm

Re: few sound questions

Post by Aisuu »

2. You can use delayedCall function?
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: few sound questions

Post by Isaac »

Drakkan wrote:1. Somebody has some tips what is the best supported format for files in direction of size (I do not care about quality). Curently I am using waw PCM signed 16 bit, mono and like 1 sec has 100kb. is there some lower supported solution ?
I believe that's the only format supported for sound effects. The sample rate might need to be 44100 to avoid multi-platform issues.
[Background audio can be ogg]

* I do wish sound effects could be ogg as well. :(
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: few sound questions

Post by Drakkan »

Isaac wrote:
Drakkan wrote:1. Somebody has some tips what is the best supported format for files in direction of size (I do not care about quality). Curently I am using waw PCM signed 16 bit, mono and like 1 sec has 100kb. is there some lower supported solution ?
I believe that's the only format supported for sound effects. The sample rate might need to be 44100 to avoid multi-platform issues.
[Background audio can be ogg]

* I do wish sound effects could be ogg as well. :(
well, even 16 bit, stereo is working, but size is double... yes, wish that ogg as well :/
Aisuu wrote:2. You can use delayedCall function?
not sure why, but following is not working

Code: Select all

function ring()
playSound("bell")
delayedCall(mojskript,5,"ring2") 
end

function ring2()
playSound("bell")
end
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: few sound questions

Post by Isaac »

Barring ogg sound effects... I wish the DAT file compression was better for mod files. I defined a 34,083 kilobyte sound effect [ :D Aqualung ], and the exported dat file was 30,127 kb. When I made a 256kbit_mono ogg of Aqualung it was 9,791kb.

It seems that ogg compressed RIFF wav files exist ~and play with the right codec, but I've seen at least one reporting of where the codec caused problems in Windows 8. :?
minmay
Posts: 2789
Joined: Mon Sep 23, 2013 2:24 am

Re: few sound questions

Post by minmay »

IIRC the dat file compression is just zlib, so it won't have special handling for different filetypes (aside from Huffman encoding for text).

You should always encode sounds at 44100Hz. Other sample rates may work for you, but this is not necessarily the case on other platforms. Many Grimrock 1 mods are impossible for Mac/Linux users to play because of modders that ignore this. Grimrock 2 hasn't been ported to non-Windows platforms yet, but it certainly might be in the future. For the same reason (and also because it makes no sense whatsoever) you should never play a stereo sound as a 3D sound. Playing a mono sound as a 2D sound is ok.
If you want to use a lower sample rate to save on file size, Grimrock 2 provides a way to accomplish that: SoundComponent:setPitch(number). This will multiply that SoundComponent's sample's speed by the given number when it is played. Therefore, if you want to use a sound at 22050Hz, just encode the 22050Hz data at 44100Hz, and when you play it, set the pitch to 0.5 (22050/44100). Obviously the interpolation will not be as good as your audio editor's but you're already playing something below 44100Hz so you obviously don't care about the quality that much.
This method probably doesn't work very well, or at all, for higher sample rates, though. Also the pitch multiplier can't go higher than 2.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply