HI .... I am a beginner programmer and we are required at college to create a very simple game as a console application :(

We found a graphics library for that... thank God....

But we need a sound and video library... but please consider that it should be:
1. For console applications
2. Can be added to visual c++ 6 , and please show me how to do that :)

Thanks in advance :D

....
for sound use fmod or something, you can't do video in a *console* application.

You can get FMOD from here.

But if you don't use Visual Studio you need to use the C API, not the C++ one.
I used fmod once, it's pretty easy and straightforward. Here's some of my test code. I compiled it in Dev-C++.

#include <cstdlib>
#include <iostream>
#include "fmod/fmod.h"
#include "fmod/fmod_errors.h"
using namespace std;

FMOD_RESULT result;
FMOD_SYSTEM *fsystem;
FMOD_SOUND *sound;
FMOD_CHANNEL *channel;

void fmod_err(FMOD_RESULT result) {
     printf("Error in FMOD: (err=%d) %s\n", result, FMOD_ErrorString(result));
     exit(1);
}

void ERRCHECK(FMOD_RESULT result) {
     if(result != FMOD_OK) fmod_err(result);
}

void stuff() {
     // do stuff with FMOD
     
     // load sound
     result = FMOD_System_CreateStream(fsystem, "linch.mp3", FMOD_DEFAULT, 0, &sound);
     ERRCHECK(result);
     
     result = FMOD_System_PlaySound(fsystem, FMOD_CHANNEL_FREE, sound, false, &channel);
     ERRCHECK(result);

     /* fmod doc says to do this, but I don't (and it still works fine) I guess it updates channel info:
     while(true) {
         FMOD_System_Update(fsystem);
     }*/
}

int main(int argc, char *argv[])
{
    //FMOD_RESULT result;
    
    result = FMOD_System_Create(&fsystem);
    if(result != FMOD_OK) fmod_err(result);
    
    result = FMOD_System_Init(fsystem, 5, FMOD_INIT_NORMAL, 0);
    if(result != FMOD_OK) fmod_err(result);
    
    stuff();
    
    
    system("PAUSE");
    return EXIT_SUCCESS;
}

I have downloaded it, but the demos are not working....
I tried your code.... but he couldn't find the library called fmod/fmod.h
How do we add this? .... Thank you.... Forgive me ... I am a beginner :D

Go to "C:\Program Files\FMOD SoundSystem\FMOD Programmers API Win32\api" - assuming you're on Windows - and copy fmodex.dll to your binary directory (one with your compiled .exe).
Then go to the lib directory and read "which library do I use.txt", copy that to your working directory and import it into your IDE as a linker library.

Then go back and go to the inc directory, copy all of that and make a new directory in your source directory called "fmod", then try to compile it.

(sorry I'm not good at explaining things.)

Go to "C:\Program Files\FMOD SoundSystem\FMOD Programmers API Win32\api" - assuming you're on Windows - and copy fmodex.dll to your binary directory (one with your compiled .exe).
Do you mean by this, i should copy it to the folder containing the vc++ project?

Then go to the lib directory and read "which library do I use.txt", copy that to your working directory and import it into your IDE as a linker library.
I don't understand this step... what did you mean by copy that? you mean the name of the library, right?... And please explain to me how to link a library...what is the working directory? What is the IDE?
I am using visual c++ 6 and windows xp :)


Then go back and go to the inc directory, copy all of that and make a new directory in your source directory called "fmod", then try to compile it.

I understand this step, but shouldn't we put (.h) files in the headers directory?

(sorry I'm not good at explaining things.)
You're good at explaining.... It is just that there are too many expressions in programming I haven't learned yet ;)

Thanks for your patience

Your IDE is Visual C++ 6.

1) Yeah, copy fmodex.dll into your project dir\bin

2) Yeah, copy the name of the library. To link one, just add #pragma comment(lib, "libraryname.lib") in your main source file (forgot how to do it the other way).

3) Yeah, but there's a few of them so it's best to put them in an fmod/ directory.

Thanks hacker9801 .... Sorry for not thanking you immediately :)

I have successfully followed your steps and tried your code above,
but I can't run the demos of the FMOD packages even when I follow your steps.

However, I need you to help me in something else....
now I know how to play a sound file and i have discovered that playing a sound doesn't stop the previous sound....
BUT how can we pause, stop, or loop a sound file?

If possible, can you show me a piece of code that contains the functions I mentioned plus any other functions that you think are useful for the game?

I know I am asking too much, but please help me :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.