Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check VOC file loading #4

Open
nick7inc opened this issue Jun 8, 2022 · 8 comments
Open

Check VOC file loading #4

nick7inc opened this issue Jun 8, 2022 · 8 comments

Comments

@nick7inc
Copy link

nick7inc commented Jun 8, 2022

Hello. I am use Allegro 4.2.1 and [found] (liballeg/allegro5#1341 (comment)), that one VOC file loads incorrectly in my 4.2.1 and Allegro 5 voc load function. I successfully backports _al_load_voc_f() from 5 to 4.2.1. If someone can check this file in 4.2.2 I can give my _al_load_voc_mod() function adopted for 4.2.1.

@nick7inc
Copy link
Author

Source code is added in mentioned topic.

@msikma
Copy link
Owner

msikma commented Jun 13, 2022

Hi @nick7inc. Thanks for your comment. I'm gonna be honest: I'm not really much of a C programmer, besides a few small experiments. The only thing I did for this repo is make sure it cross compiles correctly on DJGPP. As I understand it, there's a bug in 4.2.1 _al_load_voc_f() which you have fixed in the code in your comment, and it should be checked with the same file in 4.2.2 to see if the fix can be backported, correct?

I'll try to have a look at it soon, but I'm not sure I can actually verify myself if the fix works correctly and doesn't break anything else because I just don't have the experience for that.

@nick7inc
Copy link
Author

nick7inc commented Jun 13, 2022

Yes, _al_load_voc_pf() (to be correct) in Allegro4. It is loads only 1st block of VOC file (only first 2 of total 12 seconds). The _al_load_voc_f() from original Allegro5 do the same, but has more complex (and commented) code, so I could fix it to load whole VOC file from DukeNukem3D GRP resource file.

If you will have troubles, let me know (I use old MinGW, it is GCC-type compiler as well as DJGPP). If I'll have time (and health) I can try to convert C++ into C. I also have little experience in C, but the most code of _al5_uload_voc_mod() is C-type code. You need to get rid of template, refference, class (may be - enum) and little correct structure to fit C restrictions.

@nick7inc
Copy link
Author

enum is supported by C, but not a bool type. I done it! Just need to test if it is works.

@nick7inc
Copy link
Author

nick7inc commented Jun 14, 2022

patch.zip
You need Allegro4.C\allegro4_patch.c file. You can compare it with my CPP version Tested Allegro4 C++ with UFILE\al_voc.cpp and original Allegro 5 file.

@nick7inc
Copy link
Author

And useful function:

  inline float get_sample_instance_time(const struct SAMPLE *spl)
{
   if (!spl) return 0.0;
   return (float)(spl->len) / (float)spl->freq;
}

@msikma
Copy link
Owner

msikma commented Jun 14, 2022

I don't actually understand where this file and that function are supposed to go. Is there any chance you could make this into a PR?

@nick7inc
Copy link
Author

I have no Allegro 4.2.2 source code, and no experience with git-specific actions (what is the PR-?).

  1. You need to find, in which *.c file function load_voc_pf() with body exist, comment it (do not remove, old code).
  2. Open my allegro4_patch.c file (I forget to rename load_voc_pf_mod() back to load_voc_pf(), so do it), copy this function, _al_count_to_channel_conf() function, #define READNBYTES, all enums, init_AL_VOC_DATA() function and struct AL_VOC_DATA definition. May be there is some macros in orign Alegro 4.2.2 *.c file.
    May be if you send me the *.c file with old load_voc_pf() implementation I can patch it by myself, but I have to go into a hospital, don't know when I can do it.

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

No branches or pull requests

2 participants