![]() |
#1 |
Adept
Join Date: Mar 2016
Posts: 194
![]() |
RFC: Reworking sound sub-system
Now that my character is dead, I can get back to coding
![]() I'm not sure if anyone is the designated 'maintainer' of the messaging sub-systems, so I thought I should run this be the dev team to make sure I'm not treading on any toes... I've been looking at the interaction between the 'sound' and 'message' code and I think I can see a way to clean up the code somewhat - in particular the use of #include "list-message.h" into a static array no less than three times in message.c I think there is some scope to make 'sound' a much cleaner hook into the 'message' sub-system Let's look first at the message queue: Code:
typedef struct _msgqueue_t { message_t *head; message_t *tail; msgcolor_t *colors; u32b count; u32b max; } msgqueue_t; I propose: 1. Moving the colours out of here and create a new array (of size MSG_MAX) of structures that contain the colour and sound definitions 2. Reformat sound.cfg to be like messages.prf - something like: Code:
sound:DISSARM:plm_bang_ceramic plm_chest_latch plm_click_switch3 4. Get rid of message_lookup_by_sound_name() and message_sound_name() (no longer needed as they are used to map the current sound.cfg names to MSG_ numbers) 5. Replace calls to sound() with calls to msgt(), so Code:
sound(MSG_MULTIPLY); Code:
msgt(MSG_MULTIPLY, ""); Code:
msg("You feel stronger!"); Code:
msgt(MSG_STAT_GAIN, "You feel stronger!"); Notice that I removed the file extension from sound.cfg (I think we can safely assume a rename to sound.cfg is in order btw). We can leave it up to each individual platform to support whatever format they can (possibly even multiple formats if we like). This brings me to the final part of the cleanup (and I've mentioned this in a previous post) - moving the processing of sound.prf into a single location with hooks that each platform sets for the initialisation, loading, playing, and unloading of sounds EDIT: We could just move the sound file names into message.prf Code:
message:<message-type>:<color>:<sound file> <sound file> ... <sound file> |
![]() |
![]() |
![]() |
#2 |
Vanilla maintainer
Join Date: Apr 2007
Location: Canberra, Australia
Age: 57
Posts: 9,426
Donated: $60
![]() ![]() |
I've done very little with the sound system, but what you're suggesting sounds sensible.
One thing I have thought is that the text (with formatting where necessary) of every game message should be in a text file. I don't think that really affects what you're doing, but maybe... ...actually, maybe it does. I don't think you want sound file names in a message text file, but you could have messages indexed by labels, like Code:
label:MSG_STAT_GAIN text:You feel %s color:r Just thinking aloud, really, but keep the messages->text file idea in mind.
__________________
One for the Dark Lord on his dark throne In the Land of Mordor where the Shadows lie. |
![]() |
![]() |
![]() |
#3 |
Adept
Join Date: Mar 2016
Posts: 194
![]() |
Good thinking 99
I'll work on the message/sound hooks first, then look at extracting message text into a pref file |
![]() |
![]() |
![]() |
#4 | |
Veteran
Join Date: Apr 2007
Posts: 1,950
Donated: $40
![]() |
Quote:
__________________
takkaria whispers something about options. -more- |
|
![]() |
![]() |
![]() |
#5 | ||
Veteran
Join Date: Apr 2007
Posts: 1,950
Donated: $40
![]() |
Hey, I'm familiar with the code and I think your plans are great and it's been needing doing for some time, especially standardising the file format and stopping every single different port reimplementing it. Here are the two comments I had that weren't "hurrah!":
Quote:
Quote:
__________________
takkaria whispers something about options. -more- |
||
![]() |
![]() |
![]() |
#6 | |
Vanilla maintainer
Join Date: Apr 2007
Location: Canberra, Australia
Age: 57
Posts: 9,426
Donated: $60
![]() ![]() |
Quote:
![]()
__________________
One for the Dark Lord on his dark throne In the Land of Mordor where the Shadows lie. |
|
![]() |
![]() |
![]() |
#7 |
Adept
Join Date: Mar 2016
Posts: 194
![]() |
Here's a first pass at reworking the guts of the sound sub-system
http://pastebin.com/etTuuFJZ It compiles, but it doesn't work (crashes) - job for tommorow (technically later today - it's nearly 4am) You should get the general jist of it |
![]() |
![]() |
![]() |
#8 | |
Vanilla maintainer
Join Date: Apr 2007
Location: Canberra, Australia
Age: 57
Posts: 9,426
Donated: $60
![]() ![]() |
Quote:
One thing you will definitely have to do is add yourself to the copyright statement at the top of the relevant files.
__________________
One for the Dark Lord on his dark throne In the Land of Mordor where the Shadows lie. |
|
![]() |
![]() |
![]() |
#9 |
Adept
Join Date: Mar 2016
Posts: 194
![]() |
Thanks for the review Nick
There were only a couple of minor problems with the code (useing mem_alloc() instead of mem_zalloc() was the main one) So SDL sound works with the new code. Happy days |
![]() |
![]() |
![]() |
#10 |
Adept
Join Date: Mar 2016
Posts: 194
![]() |
Ironed out all the bugs and tidied up the code
The latest version of the new sound sub-system is here: http://pastebin.com/X15SE1id Looking forward to a in-depth review of this. A few 'nice' features: - I'm using an AVL (balanced binary) tree to store sound and mapping information so there should be a lot less memory used by the sound sub system (EDIT: The old system loaded sounds multiple times - once for EVERY instance in the sound config) - sounds are now defined in a .prf file chainloaded by pref.prf so now it's trivial to re-assign sounds (and even have sounds assigned per-class and per-character) in user preference files - file extensions are not used in the sound.prf file - it is up to the platforms sound module to search add supported extensions - SDL handles mp3 and ogg now. Adding new extensions is trivial (see supported_file_types[] in snd_sdl.c) - Did I mention balanced trees? I'm sure there are lots of other places we can use them - The only thing main.c now know about sound is to call init_sound() |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Reworking the entire magic system (yay)! | TricksterWolf | Development | 8 | September 20, 2015 21:22 |
Mk build system? | CJNyfalt | Development | 11 | March 25, 2015 08:25 |
Resist system | Jungle_Boy | Development | 65 | August 30, 2011 04:10 |
Combat System | Sirridan | Development | 9 | July 14, 2009 08:11 |
RFC: Middle Earth map for Un in ASCII; is it readable? | Bandobras | Variants | 13 | November 25, 2007 04:15 |