I will attach the current code of the audio for sdl. The issue is that if I don't have
screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
uncommented out; I am not able to use my events. Worse it will not let opengl render over SDL.
I will not let me upload the file so here is the code.
/*This program is a test program for using SDL Mixer to create sound in programs
Music and file loading on program works great. I just need to figure out how to control audio effect events without
SDL needing to create a screen.
I also need to put this into a function
Note: The only issue with the program is that I can't controly my audio effect events unless I let SDL create a screen*/
#include "SDL_mixer.h" //This include library directory may change on different machines
//SDL sound function
SDL_Surface *screen; //test
screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); //test
Mix_Chunk* effect1; //new varible to create effects from SDL lib
Mix_Music* music; //used to create the music
Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT,2, 4096);//require 4 parameters ( references (default 22050 or 41000), format(how to open,number of channels , chunk size)
music = Mix_LoadMUS("Train.wav"); //assigns music to load Mix_LoadMUS(filenam. filetype)
//Assiging music to load
//Playing the music
Mix_PlayMusic(music,-1);//Telling program to play the music (play music file, how long to play 0 = play once, -1 = repeat, 1 = will repeat once)
//now to control the effect when key is pressed
bool running=true; //boolean expression to make true
case SDLK_1: //number key 1 can be pressed
Mix_PlayChannel(-1, effect1, 0);// there are a total of 8 channels (channel, effect to play, how to repeat)
case SDLK_2: //number key 1 can be pressed
running = false;
int main(int argc,char** argv)
Edited by dreamslayerx, 24 October 2012 - 07:47 PM.