|
|
| Problem with midi.c, perhaps a bug? |
|
Janbalik
Member #12,221
August 2010
|
Hi all, Is there any way to modify this code to delete that instruction? I have tryed to do it and recompile Allegro, but the code executed is the old one and not my modified midi.c. I'm working with Code:Blocks and Mingw32 in Windows 7, Allegro version 4.2.2 but perhaps I have not recompile it in the right way. I have done it using a console window with administrator permisions and the following instructions: fix.bat mingw32 If you want to check what I say, I have attached a small midi file created by my program. If you play it with a player like winamp or windows media player you can see its drums are not the standard ones, in other words, it sounds as it should. But if you play the file using a player based on the function play_midi from midi.c (which is the function that uses the piece of code I have detailed above) you can hear the drums are the standard ones. Here is a simple code of a wav/midi player based on that midi.c function: http://altair.lcc.uma.es/clases/laboratorio/curso200203/tutoriales/Sonidos.pdf Thanks in advance. Any comment will be very appreciated.
|
|
Ron Novy
Member #6,982
March 2006
|
Wow... I haven't been here in so long I almost couldn't remember my password... Anyway, you're absolutely right. It's a bug. It's been there forever and that must be why some music has always sounded a bit different in Allegro. There also may be other checks against channel 9 (or MIDI channel 10) so take another look through the code just to be sure... Also be sure the Allegro library (liballeg.a) is being copied to the correct folder in the MinGW installation. If you installed MinGW yourself then that would be something like 'C:\MinGW\lib'. If you got MinGW with CodeBlocks then it would be a sub-folder of your CodeBlocks installation like 'C:\Program Files\Code Blocks\MinGW\lib' or something similar to that. In another case where you have two installations of MinGW you may be installing Allegro to C:\MinGW when CodeBlocks is using the one in it's sub-folder... ... mingw32-make clean ---- |
|
Janbalik
Member #12,221
August 2010
|
Hi Ron, I have checked the Allegro library and it is in the correct folder. I have also checked if the code has more places where the channel 9 is considered to do or not to do something and I have found more checks, but they are not related with this problem. In fact, I have change manually the values by debug in the piece of code I said yesterday and... wow! then the Allegro player sounds as it should, so I'm pretty sure the problem is only this function and the check against channel 9. As you suggested, my last choice was to recompile again. I have done it using the "clear" instruction but then, when I recompile the process crashes and says that the file gdi.c has an error Then I have uninstalled Codeblocks, Mingw and Allegro and reinstalled all again, but replacing the midi.c file with my own midi.c. Then, the compilation works right and everything seems to be ok. I have recompile my program, run and... I'm getting crazy. Has anyone any idea? I don't know what more can I do. Thank you very much, and specially thanks to Ron and Elias for trying to help me. I appreciate it a lot.
|
|
Thomas Fjellstrom
Member #476
June 2000
|
Make sure you don't have an old allegro dll laying about anywhere. You need to be using the new one you just compiled. -- |
|
Ron Novy
Member #6,982
March 2006
|
Just to be sure... You used clean and not clear, veryclean or distclean? If you used veryclean then you'll have to reinstall the library because that erases some specially generated files... Just be sure to backup any modified files first. I can't be too sure of what's going on, but when you run the program it's probably using a version of the Allegro DLL that is somewhere else on your system... Like C:\Windows\System32 maybe?? So even if you re-compile the library it won't matter because it is still using the old DLL elsewhere on your hard drive. Since you're using a modified version of the library, I think the best bet for you is to static link to the allegro library. Since the official 4.2.2 DLL doesn't have those modifications, this will prevent the use of the wrong DLL if you distribute your app later on... mingw32-make STATICLINK=1 mingw32-make STATICLINK=1 DEBUGMODE=1 mingw32-make install STATICLINK=1 mingw32-make install STATICLINK=1 DEBUGMODE=1 This will build the liballeg_s.a and liballd_s.a libraries. All you should need to do is change your project to link with those instead and then add the ALLEGRO_STATICLINK to your compiler define section... That should do it All the information for static linking should be available in the file "Allegro\Docs\Build\mingw32.txt" [edit] Arg... Thomas Fjellstrom! ---- |
|
Janbalik
Member #12,221
August 2010
|
Thank you for your answers and your help. You both were right, there was an old dll. And sorry, it was a mistake when I was typing. I wanted to say "clean", as you suggested, Ron. I followed your instructions as you told me. Well, I have tried to static link the Allegro library. The issue now is that nothing works. I gess there is something I have to specify to the linker but I don't know what because I have followed all the steps you told me and I have reviewed if there is something else in the allegro documentation, but I have not found what is not right. I have set the two static libraries liballeg_s.a and liballd_s.a in the linker section of the project and I have defined the ALLEGRO_STATICLINK in my code but as it doesn't work I have set also the libraries in the global section of Codeblocks. No success. I get a lot of errors like these: C:\CodeBlocks\MinGW\allegro\lib\mingw32\liballd_s.a(wsystem.o)||In function `sys_directx_desktop_color_depth':| ... I don't know what more I have to set in the linker section or any other. In the other hand, the allegro DLL library I was using is a downloaded one. I have not build this and following the steps for installing/compilling the allegro library the DLL file is never created. I have trying to recreate it but I have had no success, so using static or dynamic link I don't get what I need. I'm about to give up and leave the program working doing changes only to the no drums instruments.
|
|
Thomas Fjellstrom
Member #476
June 2000
|
If you go static, you need to link to a bunch of extra libraries manually. I don't personally remember the full list for windows. But someone else should, and should follow up with it. -- |
|
Ron Novy
Member #6,982
March 2006
|
Ah yes... Sorry, it's been so long I forgot... If I have it right, here are the other libraries you need to link to. Just go to 'Project'->'Build Options' Hit the 'Linker' tab... And just copy and paste this: -lalleg_s -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lole32 -ldinput -lddraw -ldxguid -lwinmm -ldsound to the 'Other linker options' section... This is the same as adding each library in the Libraries section only I think this is just easier. As long as either alleg_s or alld_s are the first in the list it should work. And be sure you don't include any libraries twice by adding them to the Libraries section and the Other options section... Anyway, that should do it... Even though I said that already ---- |
|
Janbalik
Member #12,221
August 2010
|
You are my idols! Thank you very much. Ron, I have specified those libraries and now it works perfectly!! Any instrument change takes effect, even if I change the drum kit instrument. Now I have total control of the tracks of my autocomposer. That was the last step to complete the first prototype of my application so... I'm very happy! Thanks, thanks, thanks! I would have been not able to do it without your help. I'm very grateful to you.
|
|
Ron Novy
Member #6,982
March 2006
|
No problem Janbalik... Music and audio are some of my main interests so I hope we get to see your application sometime. Have a great time coding. ---- |
|
|