Пример #1
0
Plane::Plane(std::string meshdir, std::string texturedir, Vector3 position)
: MovingObject(meshdir, texturedir, position, false){
	this->speed        = 0;
	this->acceleration = 50;
	this->deceleration = 5;
	this->max_speed	   = 200;
	this->min_speed	   = 50;
	this->std_speed    = 5;
	this->roll         = 3;
	this->v_roll       = 2;
	this->h_roll       = 1;
	this->friction     = 0.01;

	numBullets   = 10000;
	bulletsShoot = 0;

	cadencia = 0.25;

	name_ = "Plane " + id;

	motor = BASS_SampleLoad(false,"..\\..\\data\\sound\\motor.mp3",0,0,3,BASS_SAMPLE_LOOP);
	motorSampleChannel = BASS_SampleGetChannel(motor,false);
	BASS_ChannelPlay(motorSampleChannel,true);
	BASS_ChannelSetAttribute(motorSampleChannel,BASS_ATTRIB_VOL,0.5);
	BASS_ChannelSet3DAttributes(motorSampleChannel,BASS_3DMODE_NORMAL,1,500,360,360,0.1);

	bullet = BASS_SampleLoad(false,"..\\..\\data\\sound\\shot.mp3",0,0,3,0);
	bulletSampleChannel = BASS_SampleGetChannel(bullet,false);
	BASS_ChannelSetAttribute(bulletSampleChannel,BASS_ATTRIB_VOL,0.7);
	BASS_ChannelSet3DAttributes(bulletSampleChannel,BASS_3DMODE_NORMAL,0,500,360,360,0.1);
}
EkgWidget::EkgWidget(AnalysisManager &anaman, Widget *parent) : Widget(parent), _anaman(anaman) {
	_beatt = 1.f;
	_sound = false;
	setSizeHint(Widgets::Size(300,32));

	_beepSample = BASS_SampleLoad(false, "data/ekg.wav",0,0,10,0);
}
Пример #3
0
void AddClicked(GtkButton *obj, gpointer data)
{ // add a channel
	int resp=gtk_dialog_run(GTK_DIALOG(filesel));
	gtk_widget_hide(filesel);
	if (resp==GTK_RESPONSE_ACCEPT) {
		char *file=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filesel));
		DWORD newchan;
		// Load a music or sample from "file"
		if ((newchan=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_RAMP|BASS_SAMPLE_LOOP|BASS_SAMPLE_3D,1))
			|| (newchan=BASS_SampleLoad(FALSE,file,0,0,1,BASS_SAMPLE_LOOP|BASS_SAMPLE_3D|BASS_SAMPLE_MONO))) {
			Channel *c;
			chanc++;
			chans=(Channel*)realloc((void*)chans,chanc*sizeof(Channel));
			c=chans+chanc-1;
			memset(c,0,sizeof(Channel));
			c->channel=newchan;
			BASS_SampleGetChannel(newchan,FALSE); // initialize sample channel
			{ // add it to the list
				GtkTreeView *tree=GTK_TREE_VIEW(GetWidget("channels"));
				GtkListStore *tm=GTK_LIST_STORE(gtk_tree_view_get_model(tree));
				GtkTreeIter it;
				gtk_list_store_append(tm,&it);
				gtk_list_store_set(tm,&it,0,strrchr(file,'/')+1,-1);
			}
		} else
			Error("Can't load file (note samples must be mono)");
		g_free(file);
	}
}
Пример #4
0
/// <summary>
/// Reproduce un sonido a efecto de realizar pruebas (LShift + H).
/// </summary>
void CSoundManager::TestSound ()
{
	DWORD TestSoundId = BASS_SampleLoad(false, "Data/Sounds/Sample/Muerte/swordSwing.wav", 0, 0, 1, BASS_SAMPLE_MONO);

	// Inicializa el canal 
	BASS_SampleGetChannel(TestSoundId, FALSE);
	// Añade la configuración del canal 
	m_bIsOk = BASS_ChannelSetAttribute(TestSoundId, BASS_ATTRIB_VOL, 100)?true:false;

	// Asigna propiedad de loop
	//BASS_ChannelFlags(TestSoundId, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); // set LOOP flag

	// Generador de float aleatorio dentro del siguiente rango [-60....0....+60]  
	//float randomSemitoneValue = (rand() % ((-60) - 60 + 1)) + (-60);


	// TO DO: No funciona
	//bool worked = BASS_ChannelSetAttribute(TestSoundId,BASS_ATTRIB_TEMPO_PITCH,randomSemitoneValue)?true:false;

	//if (worked == false)
	//{
	//	int errorCode = BASS_ErrorGetCode();
	//	errorCode = 0;
	//}


	// Reproducción del canal 
	BASS_ChannelPlay(TestSoundId, FALSE);
}
Пример #5
0
MenuItem::MenuItem(const Id & parentID, eMenuItmType type, hCFG cfg, const char *section)
: GameID(this), m_parentID(parentID), m_type(type), m_cursorOffset(0,0,0), m_mID(0),
  m_scale(1,1,1), m_actionSnd(0)
{
	char buff[MAXCHARBUFF]={0};

	//load user ID
	int mID = CfgGetItemInt(cfg, section, "ID");

	if(mID >= 0)
		m_mID = mID;

	//load cursor offset
	if(CfgGetItemStr(cfg, section, "cursorOfs", buff))
		sscanf(buff, "%f,%f,%f", &m_cursorOffset.x, &m_cursorOffset.y, &m_cursorOffset.z);

	//set links to -1
	for(int i = 0; i < MITM_MAX; i++)
		m_link[i] = -1;

	//load links
	if(CfgGetItemStr(cfg, section, "links", buff))
		sscanf(buff, "%d,%d,%d,%d", &m_link[MITM_UP], &m_link[MITM_DOWN], &m_link[MITM_LEFT], &m_link[MITM_RIGHT]);

	//load sound
	if(CfgGetItemStr(cfg, section, "actionSnd", buff))
	{
		string sndPath(GAMEFOLDER);
		sndPath += "\\";
		sndPath += buff;

		m_actionSnd = BASS_SampleLoad(FALSE, (void *)sndPath.c_str(), 0, 0, 10, 0);
	}
}
Пример #6
0
TError LoadedSample::Init()
{
   if( GetFilename() ) 
   {
		const char *file = GetFilename()->ToCString();
		m_sample  = BASS_SampleLoad( FALSE, file, 0, 0, 3, 0 ); 
		m_channel = BASS_ChannelPlay( m_sample, m_playing );
   }

    return OK;
}
Пример #7
0
bool cSoundEffect::create(int num, TCHAR** p_szSoundEffect)
{
	m_vecSamples.clear();

	for(int i = 0; i < num; i++)
	{
		HSAMPLE hSample = BASS_SampleLoad(FALSE, p_szSoundEffect[i],
			0, 0, 4, 
			BASS_UNICODE | BASS_SAMPLE_OVER_VOL);

		m_vecSamples.push_back(hSample);
	}

	return true;
}
Пример #8
0
void ClientGame::LoadResources()
{

    struct TextureLoad
    {
        Texture*    texture;
        const char* fileName;
    };

    TextureLoad load[] = 
        { 
            { &m_agentTexture,                          "assets/agent.png"                          },
            { &m_agentHackingTexture,                   "assets/agent_hacking.png"                  },
            { &m_agentIntelTexture,                     "assets/agent_intel.png"                    },
            { &m_agentStakeoutTexture,                  "assets/agent_stakeout.png"                 },
            { &m_intelTexture,                          "assets/intel.png"                          },
            { &m_buildingTowerTexture,                  "assets/building_tower.png"                 },
            { &m_buildingBankTexture,                   "assets/building_bank.png"                  },
            { &m_buildingHouseTexture,                  "assets/building_safehouse.png"             },
            { &m_buildingRaidedHouseTexture,            "assets/raided_safehouse.png"               },
            { &m_buildingPoliceTexture,                 "assets/building_police.png"                },
            { &m_buttonTexture[ButtonId_Infiltrate],    "assets/action_infiltrate.png"              },
            { &m_buttonTexture[ButtonId_Capture],       "assets/action_capture.png"                 },
            { &m_buttonTexture[ButtonId_Stakeout],      "assets/action_stakeout.png"                },
            { &m_buttonTexture[ButtonId_Hack],          "assets/action_hack.png"                    },
            { &m_buttonTexture[ButtonId_Intel],         "assets/action_drop.png"                    },
            { &m_buttonShadowTexture,                   "assets/button_shadow.png"                  },
            { &m_playerPortraitTexture,                 "assets/player_portrait.png"                },
            { &m_playerEliminatedTexture,               "assets/player_eliminated.png"              },
            { &m_playerBankHackedTexture,               "assets/player_bank_hacked.png"             },
            { &m_playerCellHackedTexture,               "assets/player_cell_hacked.png"             },
            { &m_playerPoliceHackedTexture,             "assets/player_police_hacked.png"           },
            { &m_titleBackgroundTexture,                "assets/title_background.png"               },
            { &m_titleTextTexture,                      "assets/title_text.png"                     },
            { &m_uiTexture,                             "assets/ui.png"                             },
        };

    int numTextures = sizeof(load) / sizeof(TextureLoad);
    for (int i = 0; i < numTextures; ++i)
    {   
        Texture_Load(*load[i].texture, load[i].fileName);
    }

    Font_Load(m_font, "assets/font.csv");

    m_soundAction   = BASS_SampleLoad(false, "assets/sound_action.wav", 0, 0, 3, BASS_SAMPLE_OVER_POS);
    m_soundDeath    = BASS_SampleLoad(false, "assets/sound_death.wav", 0, 0, 3, BASS_SAMPLE_OVER_POS);
    m_soundDrop     = BASS_SampleLoad(false, "assets/sound_drop.wav", 0, 0, 3, BASS_SAMPLE_OVER_POS);
    m_soundHack     = BASS_SampleLoad(false, "assets/sound_hack.wav", 0, 0, 3, BASS_SAMPLE_OVER_POS);
    m_soundPickup   = BASS_SampleLoad(false, "assets/sound_pickup.wav", 0, 0, 3, BASS_SAMPLE_OVER_POS);
    m_soundTrain    = BASS_SampleLoad(false, "assets/sound_train.wav", 0, 0, 3, BASS_SAMPLE_OVER_POS);

    m_notificationLog.LoadResources();

}
Пример #9
0
int cacheSound (int f) {
	setResourceForFatal (f);

	if (! soundOK) return 0;

	int a = findInSoundCache (f);
	if (a != -1) return a;
	if (f == -2) return -1;
	a = findEmptySoundSlot ();
	freeSound (a);

	uint32_t length = openFileFromNum (f);
	if (! length) return -1;

	char * memImage;

	bool tryAgain = true;

	while (tryAgain) {
		memImage = loadEntireFileToMemory (bigDataFile, length);
		tryAgain = memImage == NULL;
		if (tryAgain) {
			if (! forceRemoveSound ()) {
				fatal (ERROR_SOUND_MEMORY_LOW);
				return -1;
			}
		}
	}

	for (;;) {
//		soundWarning ("  Trying to load sound into slot", a);
		soundCache[a].sample = BASS_SampleLoad(true, memImage, 0, length, 65535, 0);

		if (soundCache[a].sample) {
			soundCache[a].fileLoaded = f;
			delete memImage;
			setResourceForFatal (-1);
			return a;
		}

		warning (ERROR_SOUND_ODDNESS);
		soundCache[a].sample = NULL;
		soundCache[a].fileLoaded = -1;
		soundCache[a].looping = false;
		return -1;
	}
}
Пример #10
0
HEFFECT CALL HGE_Impl::Effect_Load(const char *filename, DWORD size)
{
	DWORD _size, length, samples;
	HSAMPLE hs;
	HSTREAM hstrm;
	BASS_CHANNELINFO info;
	void *buffer, *data;

	if(hBass)
	{
		if(bSilent) return 1;

		if(size) { data=(void *)filename; _size=size; }
		else
		{
			data=Resource_Load(filename, &_size);
			if(!data) return NULL;
		}
	
		hs=BASS_SampleLoad(TRUE, data, 0, _size, 4, BASS_SAMPLE_OVER_VOL);
		if(!hs) {
			hstrm=BASS_StreamCreateFile(TRUE, data, 0, _size, BASS_STREAM_DECODE);
			if(hstrm) {
				length=(DWORD)BASS_ChannelGetLength(hstrm);
				BASS_ChannelGetInfo(hstrm, &info);
				samples=length;
				if(info.chans < 2) samples>>=1;
				if((info.flags & BASS_SAMPLE_8BITS) == 0) samples>>=1;
				buffer=BASS_SampleCreate(samples, info.freq, 2, 4, info.flags | BASS_SAMPLE_OVER_VOL);
				if(!buffer)
				{
					BASS_StreamFree(hstrm);
					_PostError("Can't create sound effect: Not enough memory");
				}
				else
				{
					BASS_ChannelGetData(hstrm, buffer, length);
					hs=BASS_SampleCreateDone();
					BASS_StreamFree(hstrm);
					if(!hs)	_PostError("Can't create sound effect");
				}
			}
		}

		if(!size) Resource_Free(data);
		return hs;
	}
Пример #11
0
HSAMPLE BassSoundEngine::ReadSound(string filename)
{
	HSAMPLE sound;
	if(sample_pool.find(filename)!=sample_pool.end())
		sound = sample_pool[filename];
	else{
		sound = BASS_SampleLoad(FALSE, filename.data(), 0, 0, maxChannel, 0);
		sample_pool[filename] = sound;
	}

	// get the music's sampling rate
	BASS_SAMPLE info;
	BASS_SampleGetInfo(sound, &info);
	music_sampleRate = info.freq;

	return sound;
}
Пример #12
0
void BassSoundEngine::Init()
{
	nowChannel = 0;
	sampleRate_factor = pitch_factor = tempo_factor = 0;
	intended_pitch = 1.0;

	DWORD hr;
	hr = BASS_Init(-1, defaultSampleRate, BASS_DEVICE_LATENCY, base::hwnd, NULL);
	hr = BASS_FX_GetVersion();
	hitWav = BASS_SampleLoad(false, "gamedata\\hit.wav", 0, 0, 16, 0);
#if 1==0
	HSTREAM fs1, fs2;
	fs1 = BASS_StreamCreateFile(false,"D:\\Project DIVA PC\\gamedata\\cg.mp3",0,0,BASS_STREAM_DECODE);
	fs2 = BASS_FX_TempoCreate(fs1, 0);
	hr = BASS_ErrorGetCode();
	hr = BASS_ChannelPlay(fs2, FALSE);
	hr = BASS_ChannelSetAttribute(fs2, BASS_ATTRIB_TEMPO, 50); 
	Sleep(100000);
	hr = BASS_ChannelStop(fs1);
	Sleep(2000);
#endif
	hr = 0;
}
Пример #13
0
static bool Configure(SoundTemplate &self, const tinyxml2::XMLElement *element, unsigned int id)
{
	const char *name = element->Attribute("name");
	if (name == NULL)
		return false;

#if defined(USE_BASS)

	// load sound file
	HSAMPLE handle = BASS_SampleLoad(false, name, 0, 0, 1, BASS_SAMPLE_MONO);
	if (!handle)
	{
		DebugPrint("error loading sound file \"%s\": %s\n", name, BASS_ErrorGetString());
		return false;
	}

	// get sample info
	BASS_SAMPLE info;
	BASS_SampleGetInfo(handle, &info);

	// allocate space for data
	self.Reserve(info.length / info.chans);

	// set frequency
	self.mFrequency = info.freq;

	// if converting format...
	if ((info.chans > 1) || (info.flags & BASS_SAMPLE_8BITS))
	{
		// get sample data
		void *buf = _alloca(info.length);
		BASS_SampleGetData(handle, buf);

		// if converting from 8-bit...
		int accum = 0;
		if (info.flags & BASS_SAMPLE_8BITS)
		{
			for (unsigned int in = 0, samp = 0; in < info.length; ++in)
			{
				accum += static_cast<unsigned char *>(buf)[in];
				if (++samp >= info.chans)
				{
					self.Append(short(accum * 257 / samp - 32768));
					accum = 0;
					samp = 0;
				}
			}
		}
		else
		{
			for (unsigned int in = 0, samp = 0; in < info.length / sizeof(short); ++in)
			{
				accum += static_cast<short *>(buf)[in];
				if (++samp >= info.chans)
				{
					self.Append(short(accum / samp));
					accum = 0;
					samp = 0;
				}
			}
		}
	}
	else
	{
		// copy sound data
		BASS_SampleGetData(handle, static_cast<short *>(self.mData) + self.mLength);
	}

	// free loaded data
	BASS_SampleFree(handle);

#elif defined(USE_SDL_MIXER)

	// load sound file
	Mix_Chunk *loadchunk = Mix_LoadWAV(name);
	if (!loadchunk)
	{
		DebugPrint("error loading sound file \"%s\": %s\n", name, Mix_GetError());
		return false;
	}

	// copy sound data
	self.mSize = self.mLength * sizeof(short) + loadchunk->alen;
	self.mData = realloc(self.mData, self.mSize);
	memcpy(static_cast<short *>(self.mData) + self.mLength, loadchunk->abuf, loadchunk->alen);
	self.mLength = self.mSize / sizeof(short);

	// free loaded data
	Mix_FreeChunk(loadchunk);

#elif defined(USE_SDL)

	// load wave file data
	SDL_AudioSpec wave;
	Uint8 *data;
	Uint32 dlen;
	if ( !SDL_LoadWAV(name, &wave, &data, &dlen) )
	{
		DebugPrint("error loading sound file \"%s\": %s\n", name, SDL_GetError());
		return false;
	}

	// build audio conversion
	SDL_AudioCVT cvt;
	SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq,
							AUDIO_S16,   1,             AUDIO_FREQUENCY);

	// append sound data
	self.mSize = self.mLength * sizeof(short) + dlen * cvt.len_mult;
	self.mData = realloc(self.mData, self.mSize);
	memcpy(static_cast<short *>(self.mData) + self.mLength, data, dlen);
	cvt.buf = reinterpret_cast<unsigned char *>(static_cast<short *>(mData) + mLength);
	cvt.len = dlen;

	// convert to final format
	SDL_ConvertAudio(&cvt);
	self.mLength += cvt.len_cvt / sizeof(short);
	self.mSize = self.mLength * sizeof(short);
	self.mData = realloc(self.mData, self.mSize);

	// release wave file data
	SDL_FreeWAV(data);

#endif

	return true;
}
Пример #14
0
/// <summary>
/// Carga el .xml de sonido.
/// </summary>
///<param name="&FileName">Ubicación del archivo xml.</param>
bool CSoundManager::Load(const std::string &FileName)
{
	SSoundData soundData;

  bool l_bIsOk = true;
  m_FileName = FileName;
  CXMLTreeNode filexml;
  if (!filexml.LoadFile(m_FileName.c_str()))
  {
    // Guarda mensaje de error en el log
		std::string msg_error = "CSoundManager::Load->Error al intentar abrir el archivo: ";
		msg_error.append(m_FileName.c_str());
		LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str());
		throw CException(__FILE__, __LINE__, msg_error);
    l_bIsOk = false;
  }
  else
  {
    CXMLTreeNode cores = filexml["sounds"];
    if (cores.Exists())
    {
			m_iMaxChannels = cores.GetIntProperty("maxChannels");

			// Asignando número de canales de acuerdo al parametro extraído del .xml
			m_Channels.resize(m_iMaxChannels);
 
			if (!cores.IsComment())
			{
				int32 numNodes = cores.GetNumChildren();		
				for(int i=0; i < numNodes; i++)
				{
					if (!cores(i).IsComment())
					{
						// Recibe parametros de los sonidos
						std::string l_sCoreName = cores(i).GetPszProperty("name");
						std::string l_sCoreType = cores(i).GetPszProperty("type");
						std::string l_sCorePath = cores(i).GetPszProperty("path");
            bool l_bCoreLoop = cores(i).GetBoolProperty("loop");
						bool l_bCore3D = cores(i).GetBoolProperty("threeDimensional");
						std::string l_sCorePriority = cores(i).GetPszProperty("priority");
						std::string l_sCoreEffect = cores(i).GetPszProperty("effect");
            float l_fCoreVolume = cores(i).GetFloatProperty("volume");
 
						int iMask = 0;
 
						int PathLastCharacters = l_sCorePath.length() - 3;

						std::string substring = l_sCorePath.substr(PathLastCharacters,3);

						if (substring != "wav")
						{
							// Convert the sample (MP3/MP2/MP1 only) to mono, if it's not already. 
							iMask = BASS_SAMPLE_MONO;
						}
						 
						// Asigna propiedad de loop
						if (l_bCoreLoop)
						{
							iMask |= BASS_SAMPLE_LOOP;
							soundData.m_Loop = true;
						}
						else
						{
							soundData.m_Loop = false;
						}

						// Asigna propiedad 3D y posición 3D
						if (l_bCore3D)
						{
							iMask |= BASS_SAMPLE_3D;
							soundData.m_ThreeDimensional = true;
							soundData.m_Position = cores(i).GetVect3fProperty("position", Vect3f(0.0, 0.0, 0.0));
						}
						else
						{
							soundData.m_ThreeDimensional = false;
						}

						if (l_sCoreType == "sample")
						{
							// Genera identificador para sonido
							soundData.m_type = SAMPLER;
							
							soundData.m_Id = BASS_SampleLoad(false, l_sCorePath.c_str(), 0, 0, m_iMaxChannels, iMask);
						
						}
						else
						{
							// Genera identificador para música
							soundData.m_Id =  BASS_StreamCreateFile(false, l_sCorePath.c_str(), 0, 0, iMask);
							soundData.m_type = BGM;
						}
 
						// Añadiendo volumen
						soundData.m_Volume = l_fCoreVolume;

						// Añade sonido al mapa
						m_Resources[l_sCoreName] = soundData;
					}
				}
			}
    }
    else
    {
      l_bIsOk = false;
    }
  }
  return l_bIsOk;
}