Author Topic: playing DRO or IMF music files  (Read 5137 times)

0 Members and 1 Guest are viewing this topic.

Offline jessicajones

  • Newbie
  • Posts: 12
    • View Profile
playing DRO or IMF music files
« on: June 18, 2020, 03:02:15 pm »
Hi

I want to make a music player in QB64 that can play DRO and/or IMF music files.

I export the DRO and IMF music files from MS-DOS games using a tool Camoto: http://www.shikadi.net/camoto

The DRO format information: http://www.shikadi.net/moddingwiki/DRO_Format

The IMF formation information: http://www.shikadi.net/moddingwiki/IMF_Format

Is there anybody who has BASIC code to play those files? (which can run in QB64)

Thanks
Jessica

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: playing DRO or IMF music files
« Reply #1 on: June 18, 2020, 04:09:24 pm »
Hi.  QB64 doesn't support playing DRO/IMF file natively, and I've never seen any QB64 code to decode and play an IMF.  You could possibly use a helper DLL to play them, like the old IMFLib.  Or, you could convert the IMF to MID file instead - I've seen tools for doing that out there.  There are a few examples of playing MID files in QB64 floating around here. 

Maybe someone else can offer better help ...there are some very knowledgeable folks around here.  Good luck!

- Dav

Offline jessicajones

  • Newbie
  • Posts: 12
    • View Profile
Re: playing DRO or IMF music files
« Reply #2 on: June 19, 2020, 10:44:20 am »
You could possibly use a helper DLL to play them, like the old IMFLib.

Where can I download this IMFLib?

Is it open source?

Can IMFLib work inside QB64?

thx

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: playing DRO or IMF music files
« Reply #3 on: June 19, 2020, 11:00:36 am »
Where can I download this IMFLib?

Is it open source?

Can IMFLib work inside QB64?

thx
Here is a link to the IMFlib dll. A quick Google search showed me that it was used for Wolfenstein 3D. Archive.org had made a backup of the site and so the DLL is still able to be downloaded. Try it out!
https://web.archive.org/web/20151213030345/http://homepage.o2mail.de/mkroll/bins/IMFLib-1.7.zip
Shuwatch!

Offline jessicajones

  • Newbie
  • Posts: 12
    • View Profile
Re: playing DRO or IMF music files
« Reply #4 on: June 19, 2020, 10:18:31 pm »
I downloaded it but according to me it's a library for the C language. So not for qb64

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: playing DRO or IMF music files
« Reply #5 on: June 20, 2020, 11:18:18 am »
Try to find documentation for that library. It is important that you mount the library for a 32-bit system in a 32-bit IDE and a 64-bit library in a 64-bit IDE. Then there is a problem if this library calls other libraries. Without documentation, you have not the slightest chance to connect it. If it's for C, it's for QB64. Anyway, QB64 always first converts your program to C and then to EXE.
« Last Edit: June 20, 2020, 11:19:29 am by Petr »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: playing DRO or IMF music files
« Reply #6 on: June 20, 2020, 11:27:44 am »
So. This library is for 32 bit IDE. Please, upload here one sound file for this library, i try run it.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: playing DRO or IMF music files
« Reply #7 on: June 20, 2020, 11:47:49 am »
Look to begin the file named ImfLib.h:

There is writed usage. So you don't have to look for documentation. When declaring support programs and functions in the library, you must pay attention to uppercase and lowercase letters in their names, as is common in C, otherwise the program will tell you that the function does not exist in the dynamic library.

You will probably use the QB64 command _MEMNEW in memory to create a block where you will copy a part of the IMF file from the starting position of the music from the hard disk (you have to find it using the link where you have the IMF format layout you put at the beginning of this thread) and to RAM, so you send _OFFSET of this _MEM to the dynamic library. It seems to work because the dynamic link library is reporting an error when sending empty memory instead of music data.


Code: QB64: [Select]
  1.     SUB InitIMFPlayer
  2.     SUB StartIMFMusic (pointer AS _OFFSET)
  3.  
  4.  
  5. DIM NewSound AS _MEM
  6. file_music_data_size = 1024 'calculate by file music data size
  7. NewSound = _MEMNEW(file_music_data_size)
  8.  
  9. 'place file content to this new mem block here
  10. '.
  11. '.
  12. '.
  13.  
  14. PRINT _OFFSET(NewSound)
  15.  
  16. InitIMFPlayer
  17. StartIMFMusic _OFFSET(NewSound)
  18.  

You must run it under 32 bit IDE!

Offline jessicajones

  • Newbie
  • Posts: 12
    • View Profile
Re: playing DRO or IMF music files
« Reply #8 on: June 20, 2020, 02:31:40 pm »
So. This library is for 32 bit IDE. Please, upload here one sound file for this library, i try run it.

Hello

thx for the help

The attachment includes a windows exe player (not made by me, but found online) and 3 IMF test files (I believe "test.imf" is the correct one: I just saved the music in the 3 possible IMF formats available).

You can verify these file play by running the windows exe in the command prompt like this: ImfPlayer filename.imf
(also copy the file SDL.dll to the same folder)

  [ You are not allowed to view this attachment ]  

Please let me know if the library works in QB64!

My goal is to make a QB64 program that can play those IMF files.

Jessica

Offline jessicajones

  • Newbie
  • Posts: 12
    • View Profile
Re: playing DRO or IMF music files
« Reply #9 on: June 20, 2020, 02:38:09 pm »
Look to begin the file named ImfLib.h:

There is writed usage. So you don't have to look for documentation. When declaring support programs and functions in the library, you must pay attention to uppercase and lowercase letters in their names, as is common in C, otherwise the program will tell you that the function does not exist in the dynamic library.

You will probably use the QB64 command _MEMNEW in memory to create a block where you will copy a part of the IMF file from the starting position of the music from the hard disk (you have to find it using the link where you have the IMF format layout you put at the beginning of this thread) and to RAM, so you send _OFFSET of this _MEM to the dynamic library. It seems to work because the dynamic link library is reporting an error when sending empty memory instead of music data.


Code: QB64: [Select]
  1.     SUB InitIMFPlayer
  2.     SUB StartIMFMusic (pointer AS _OFFSET)
  3.  
  4.  
  5. DIM NewSound AS _MEM
  6. file_music_data_size = 1024 'calculate by file music data size
  7. NewSound = _MEMNEW(file_music_data_size)
  8.  
  9. 'place file content to this new mem block here
  10. '.
  11. '.
  12. '.
  13.  
  14. PRINT _OFFSET(NewSound)
  15.  
  16. InitIMFPlayer
  17. StartIMFMusic _OFFSET(NewSound)
  18.  

You must run it under 32 bit IDE!

Hello

I'm a QB64 beginner and can't do this myself :(
Much things I don't understand... But I really wanted a player in QB64 for imf files.

Is it possible to upload your QB64 code file here that does the following:

- use the IMFLib library in QB64 (code needed to use it)

- load a .IMF file from hard disk: let's say "test.imf"

- plays the file in QB64 using the library

Here is the library:

  [ You are not allowed to view this attachment ]  

Here is the source code of the library I found online too!

  [ You are not allowed to view this attachment ]  

I hope you can help!

Jessica

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: playing DRO or IMF music files
« Reply #10 on: June 21, 2020, 08:44:41 am »
Hi.

I wanted to give it up. The program still reported that the provided music data was too short, due to the length of the song. That was one and huge problem for me. Another problem was that I use dolby digital sound enhancements with the 5.1 speaker system by default. When I switch to 5.1, I sometimes lose stereo sound (I can't hear anything). After many attempts (about 50 attempts) it succeeded. Try it. It's playing for me. In the program (in the game), a game loop will run instead of sleep. Now it's only there to stay the program window and it doesn't stop right away, so the audio doesn't go down.

Thank you for your cooperation. Thanks to SpriggsySpriggs for finding the library and you, Jessica for providing the source code in C. I thought there must be a parameter missing from the library call and it really was. Length information was missing. If I didn't look at the C source code, I would never be able to get it up and running. And I improvised that, because I practically don't know the C language.

Code: QB64: [Select]
  1.     SUB InitIMFPlayer
  2.     SUB StartIMFMusic (BYVAL pointer AS _OFFSET, BYVAL size AS _OFFSET)
  3.     SUB ShutdownIMFPlayer ()
  4.  
  5.  
  6.  
  7.  
  8. file$ = "test.imf"
  9. T = 0
  10. OPEN file$ FOR BINARY AS ff
  11. size = LOF(ff) - T
  12.  
  13. REDIM NewSound AS _MEM
  14. NewSound = _MEMNEW(size)
  15. s$ = SPACE$(size)
  16. REM SEEK ff, T
  17. GET #ff, , s$
  18. _MEMPUT NewSound, NewSound.OFFSET, s$
  19. s$ = ""
  20. CLOSE #ff
  21.  
  22.  
  23. InitIMFPlayer
  24. StartIMFMusic NewSound.OFFSET, NewSound.SIZE
  25.  
  26. PRINT "Press any key to end. For listening set your audio to stereo and disable some dolby software!"
  27.  
  28. ShutdownIMFPlayer
  29. _MEMFREE NewSound
  30.  
  31.  

RUN IN 32 BIT IDE!
« Last Edit: June 21, 2020, 10:30:06 am by Petr »

Offline jessicajones

  • Newbie
  • Posts: 12
    • View Profile
Re: playing DRO or IMF music files
« Reply #11 on: June 21, 2020, 06:27:15 pm »
great it works!!

Thank you for all the work!

I have send you a PM for another request (if possible)
« Last Edit: June 21, 2020, 06:30:19 pm by jessicajones »

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: playing DRO or IMF music files
« Reply #12 on: June 21, 2020, 09:30:29 pm »
Great job, Petr!  I was trying to use IMFLib also, but just couldn't get it to work either.  I tried your code and it works for me too.  I also used the other functions and subs and they are working now, like SUB PauseIMFMusic and FUNCTION GetIMFPosition%.  Cool. 

- Dav

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: playing DRO or IMF music files
« Reply #13 on: June 22, 2020, 07:52:52 am »
Good Job!

Great I see a fine leader group/team about Sound in QB64.
Welcome!
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: playing DRO or IMF music files
« Reply #14 on: June 22, 2020, 10:38:12 am »
Good Job!

Great I see a fine leader group/team about Sound in QB64.
Welcome!

+1