News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Bundle and Play XM File As Resource

Started by DavidB, November 21, 2017, 05:06:26 PM

Previous topic - Next topic

DavidB

For a program that I am writing, I want to bundle an XM sound file as a program resource, and play it on a loop as part of the program. I have found several posts online that discuss doing this, but none of them adequately explain how to bundle the XM file as a resource. Do I need to depend on a MASM32 SDK library to do this, or can I stick with with the Irvine library? (I realize that this forum is not for Irvine-related questions, but since everything I have seen relies on non-Irvine libraries, I am going to assume that answer to that question is "no.")

Also, I am using Visual Studio 2017 as my IDE of choice.

Siekmanski

Hi David,

This example plays a XM music module from the resource.
Creative coders use backward thinking techniques as a strategy.

Vortex

Hi DavidB,

You can use the fda ( file data assembler ) tool supplied with the Masm32 package to convert any binary file to a MS COFF object module.

DavidB

Quote from: Siekmanski on November 21, 2017, 06:46:17 PM
Hi David,

This example plays a XM music module from the resource.

Quote from: Vortex on November 22, 2017, 06:21:06 AM
Hi DavidB,

You can use the fda ( file data assembler ) tool supplied with the Masm32 package to convert any binary file to a MS COFF object module.
Great! I used to the fda tool to convert the XM file, and as a result, I got an "inc" and "obj" file, but I cannot figure out what I am actually supposed to do with them. The example that Siekmanski provided is great, but it does not have either an inc or obj file. Also, it does not appear to have been built with Visual Studio. I would assume that from here, I would have to convert these two files to a resource file in some way?

hutch--

David,

fda.exe directly converts the file you want to include into an object module which you then link into your executable but this does not make it playable directly. At its simplest you could write the sound file to disk then run an old API PlaySound(). If you have a method of playing the file from memory, you use the start address stored in the INC file and play it directly.

As far as the differences between the Irvine system and MASM32, they are pointed at different targets, the Irvine system is aimed at getting undergraduate students through a semester of assembler where MASM32 was always pointed at production code so that you could write working applications, object modules for VC and dynamic link libraries.

DavidB

Quote from: hutch-- on November 22, 2017, 02:25:41 PM
David,

fda.exe directly converts the file you want to include into an object module which you then link into your executable but this does not make it playable directly. At its simplest you could write the sound file to disk then run an old API PlaySound(). If you have a method of playing the file from memory, you use the start address stored in the INC file and play it directly.

As far as the differences between the Irvine system and MASM32, they are pointed at different targets, the Irvine system is aimed at getting undergraduate students through a semester of assembler where MASM32 was always pointed at production code so that you could write working applications, object modules for VC and dynamic link libraries.
Well as it so happens, I have been using Irvine "to get through a semester of assembler", but I really would like to learn more about it and not cheat the system. Ideally, I would like to mix Irvine and MASM32 libraries to do this. The problem is that I cannot figure out how to modify my Visual Studio project's linker settings to include my XM as a resource.

As for playing my XM file, I was just going to use uFMOD like this (copied from Siekmanski's HTML encoder example):
invoke  uFMOD_PlaySong,ElteesSong,hinst,XM_RESOURCE

But once again, I cannot figure out how to include the uFMOD libraries in my Visual Studio project.

I realize that typically, Irvine-dependent projects are not supposed to work like this, but I'm sure someone has done it before. I just cannot find any information on how to do it myself. Another thing to consider is that all libraries that project depends on will need to be bundled with the project. I cannot rely on a MASM32 installation on the C drive because not all computer which will be used to Assemble the project will have MASM32 installed.

I found this video which details how to add Irvine32.inc to the linker (I haven't had to do this because we have been given a template project to work with), and I have a feeling that I need to do something similar with the libraries and resources that I want to add, but I am not sure if that is the case.

jj2007

See Playing XM sound files for another solution.

@Marinus: How do you get sd10menu.xm played, is that a built-in Windows decoder? For my snippet, I had to find the BassMod dll to get it playing...

DavidB

Quote from: jj2007 on November 22, 2017, 03:35:25 PM
See Playing XM sound files for another solution.

@Marinus: How do you get sd10menu.xm played, is that a built-in Windows decoder? For my snippet, I had to find the BassMod dll to get it playing...
Hmm, that's an interesting method. In all of my research of how to do this, that is a method that I have never come across. Unfortunately I am still dealing with the limitation of trying to figure out how to add resources to a MASM project in Visual Studio.

Siekmanski

\lib\ufmod.lib
\include\ufmod.inc -> look into this, it explains how to use the XM player.

You can load the .XM as a file, from resource or from memory.

You could dump the .XM as a data file, include it in your data section and play it from memory.

More info: http://ufmod.sourceforge.net/
Creative coders use backward thinking techniques as a strategy.

DavidB

Quote from: Siekmanski on November 22, 2017, 04:39:54 PM
\lib\ufmod.lib
\include\ufmod.inc -> look into this, it explains how to use the XM player.

You can load the .XM as a file, from resource or from memory.

You could dump the .XM as a data file, include it in your data section and play it from memory.

More info: http://ufmod.sourceforge.net/
Okay, thank you. I have not had a chance to look at this in-depth yet, but from the little I have looked at it, what I have to do is:


  • Get a copy of ufmod.lib and ufmod.inc and put them in the root directory of my Visual Studio project.
  • Include both files in my code.
  • Create a dat file out of my XM, which also should go in the root directory of my project.
  • Use uFMOD to play it.

What would be the difference between using the XM from memory versus from resource? I thought that using things from resource was using them from memory.

Siekmanski

Quote from: DavidB on November 22, 2017, 05:14:48 PM
Okay, thank you. I have not had a chance to look at this in-depth yet, but from the little I have looked at it, what I have to do is:


  • Get a copy of ufmod.lib and ufmod.inc and put them in the root directory of my Visual Studio project.
  • Include both files in my code.
  • Create a dat file out of my XM, which also should go in the root directory of my project.
  • Use uFMOD to play it.

Yes.  :t

\lib\ufmod.lib
\include\ufmod.inc

Both the are included in the HTMLencoder.zip example I posted.

QuoteWhat would be the difference between using the XM from memory versus from resource? I thought that using things from resource was using them from memory.

Yes,

The only difference between resource and memory:

If you include the .xm as a binary file into the resource. ( the same as, including an icon or an image file )
It will be played from resource memory.

If you don't have a resource section. ( for example a console app. or a window app. without a resource section.)
You create a data dump include file from the .xm file and include it in the data section.
It will be played from data memory.

Option 3,

Load the .xm file from disk as a seperate file. ( .xm is not incuded in the executable file. )

Creative coders use backward thinking techniques as a strategy.

hutch--

Quote
Well as it so happens, I have been using Irvine "to get through a semester of assembler", but I really would like to learn more about it and not cheat the system. Ideally, I would like to mix Irvine and MASM32 libraries to do this.
The reason why I moved your earlier post was that Kip Irvine should be providing the support for students that are using his work, there are a few here that will try and help Irvine users but finally if you choose to use his stuff, you should be getting support from him instead of dumping these questions into a forum that is designed for another purpose. Also the choice of using the VS IDE limits the amount of support you will get as many here would not touch it with a barge pole due to its size and how slow it is.

As far as combining the libraries, you are wasting your time as the Irvine libraries are not Intel ABI compliant so the register usage in Irvine examples will cause production code to crash.

DavidB

Quote from: Siekmanski on November 22, 2017, 05:44:36 PM
Quote from: DavidB on November 22, 2017, 05:14:48 PM
Okay, thank you. I have not had a chance to look at this in-depth yet, but from the little I have looked at it, what I have to do is:


  • Get a copy of ufmod.lib and ufmod.inc and put them in the root directory of my Visual Studio project.
  • Include both files in my code.
  • Create a dat file out of my XM, which also should go in the root directory of my project.
  • Use uFMOD to play it.

Yes.  :t

\lib\ufmod.lib
\include\ufmod.inc

Both the are included in the HTMLencoder.zip example I posted.

QuoteWhat would be the difference between using the XM from memory versus from resource? I thought that using things from resource was using them from memory.

Yes,

The only difference between resource and memory:

If you include the .xm as a binary file into the resource. ( the same as, including an icon or an image file )
It will be played from resource memory.

If you don't have a resource section. ( for example a console app. or a window app. without a resource section.)
You create a data dump include file from the .xm file and include it in the data section.
It will be played from data memory.

Option 3,

Load the .xm file from disk as a seperate file. ( .xm is not incuded in the executable file. )
Great! I cannot wait to try this out tomorrow! Although I am sure that I will have problems along the way that I will have to ask you about. My program is a small console application, so I'm probably going to opt for the data dump method and load it from data memory. Out of curiosity though, why would it be beneficial to use resource memory over data memory in different situations? Also, what's the deal with the "lib" and "inc" files? I realize that I am supposed to use both of them, but I am unsure of why or how entirely.

Quote from: hutch-- on November 22, 2017, 05:50:18 PM
Quote
Well as it so happens, I have been using Irvine "to get through a semester of assembler", but I really would like to learn more about it and not cheat the system. Ideally, I would like to mix Irvine and MASM32 libraries to do this.
The reason why I moved your earlier post was that Kip Irvine should be providing the support for students that are using his work, there are a few here that will try and help Irvine users but finally if you choose to use his stuff, you should be getting support from him instead of dumping these questions into a forum that is designed for another purpose. Also the choice of using the VS IDE limits the amount of support you will get as many here would not touch it with a barge pole due to its size and how slow it is.

As far as combining the libraries, you are wasting your time as the Irvine libraries are not Intel ABI compliant so the register usage in Irvine examples will cause production code to crash.
Well in fairness to me, I was not actually aware that Irvine was a big of a crutch as it apparently is. Now that I know that, I am planning on moving away from Irvine once I am done with my class which requires it, as it seems that MASM32 has its own libraries which are just as capable as Irvine's, if not more-so.

What IDE to programmers on this forum prefer? As much as I love Visual Studio for working with C++, I have to admit that I am not a fan of it as far as ASM development goes, and would love to switch to something else once I am free to do stuff on my own. At this point, my question isn't so much about Irvine usage as much as it is about doing something else in a program that uses Irvine. As for the "Intel ABI compliant" part is concerned, what does that mean? Why would it cause problems?

Siekmanski

Good idea.  :t

Click on the "MASM32 Downloads" link in the top right of this page and download the MASM SDK.
It has all you need to get started programming with MASM.
Creative coders use backward thinking techniques as a strategy.

jj2007

Quote from: DavidB on November 22, 2017, 06:13:58 PMMy program is a small console application, so I'm probably going to opt for the data dump method and load it from data memory

Console programs can also have resource sections, no problem.

Quote...a program that uses Irvine. As for the "Intel ABI compliant" part is concerned, what does that mean? Why would it cause problems?

It would not necessarily cause problems, but you would need to know exactly what you do. And in any case, Masm32 is a much more mature and powerful package. Kip's stuff is really just meant for students who need a certificate and then quickly forget what assembly is good for.