亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? t3dlib3.cpp

?? 游戲的聲音圖像演示程序
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
// T3DLIB3.CPP - Game Engine Part III, sound & music
 
// INCLUDES ///////////////////////////////////////////////

#define WIN32_LEAN_AND_MEAN  

#include <windows.h>   // include important windows stuff
#include <windowsx.h> 
#include <mmsystem.h>
#include <objbase.h>
#include <iostream.h> // include important C/C++ stuff
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <math.h>
#include <io.h>
#include <fcntl.h>
#include <direct.h>
#include <wchar.h>

#include <ddraw.h>  // directX includes
#include <dsound.h>
#include <dmksctrl.h>
#include <dmusici.h>
#include <dmusicc.h>
#include <dmusicf.h>


#include "T3DLIB3.H"

// DEFINES ////////////////////////////////////////////////


// TYPES //////////////////////////////////////////////////

// PROTOTYPES /////////////////////////////////////////////

// EXTERNALS /////////////////////////////////////////////

extern HWND main_window_handle;     // access to main window handle in main module

// GLOBALS ////////////////////////////////////////////////

// directsound stuff
LPDIRECTSOUND		lpds = NULL;    // directsound interface pointer
DSBUFFERDESC		dsbd;           // directsound description
DSCAPS				dscaps;         // directsound caps
HRESULT				dsresult;       // general directsound result
DSBCAPS				dsbcaps;        // directsound buffer caps
LPDIRECTSOUNDBUFFER	lpdsbprimary = NULL;   // the primary mixing buffer
pcm_sound			sound_fx[MAX_SOUNDS];    // the array of secondary sound buffers

WAVEFORMATEX		pcmwf;          // generic waveformat structure

// direct music globals
IDirectMusicPerformance    *dm_perf = NULL;    // the directmusic performance manager 
IDirectMusicLoader         *dm_loader = NULL;  // the directmusic loader

// this hold all the directmusic midi objects
DMUSIC_MIDI                dm_midi[DM_NUM_SEGMENTS];
int dm_active_id = -1;     // currently active midi segment

// FUNCTIONS //////////////////////////////////////////////

int DSound_Load_WAV(char *filename, int control_flags)
{
// this function loads a .wav file, sets up the directsound 
// buffer and loads the data into memory, the function returns 
// the id number of the sound


HMMIO 			hwav;    // handle to wave file
MMCKINFO		parent,  // parent chunk
                child;   // child chunk
WAVEFORMATEX    wfmtx;   // wave format structure

int	sound_id = -1,       // id of sound to be loaded
	index;               // looping variable

UCHAR *snd_buffer,       // temporary sound buffer to hold voc data
      *audio_ptr_1=NULL, // data ptr to first write buffer 
	  *audio_ptr_2=NULL; // data ptr to second write buffer

DWORD audio_length_1=0,  // length of first write buffer
	  audio_length_2=0;  // length of second write buffer
			
// step one: are there any open id's ?
for (index=0; index < MAX_SOUNDS; index++)
	{	
    // make sure this sound is unused
	if (sound_fx[index].state==SOUND_NULL)
	   {
	   sound_id = index;
	   break;
	   } // end if

	} // end for index

// did we get a free id?
if (sound_id==-1)
	return(-1);

// set up chunk info structure
parent.ckid 	    = (FOURCC)0;
parent.cksize 	    = 0;
parent.fccType	    = (FOURCC)0;
parent.dwDataOffset = 0;
parent.dwFlags		= 0;

// copy data
child = parent;

// open the WAV file
if ((hwav = mmioOpen(filename, NULL, MMIO_READ | MMIO_ALLOCBUF))==NULL)
    return(-1);

// descend into the RIFF 
parent.fccType = mmioFOURCC('W', 'A', 'V', 'E');

if (mmioDescend(hwav, &parent, NULL, MMIO_FINDRIFF))
    {
    // close the file
    mmioClose(hwav, 0);

    // return error, no wave section
    return(-1); 	
    } // end if

// descend to the WAVEfmt 
child.ckid = mmioFOURCC('f', 'm', 't', ' ');

if (mmioDescend(hwav, &child, &parent, 0))
    {
    // close the file
    mmioClose(hwav, 0);

    // return error, no format section
    return(-1); 	
    } // end if

// now read the wave format information from file
if (mmioRead(hwav, (char *)&wfmtx, sizeof(wfmtx)) != sizeof(wfmtx))
    {
    // close file
    mmioClose(hwav, 0);

    // return error, no wave format data
    return(-1);
    } // end if

// make sure that the data format is PCM
if (wfmtx.wFormatTag != WAVE_FORMAT_PCM)
    {
    // close the file
    mmioClose(hwav, 0);

    // return error, not the right data format
    return(-1); 
    } // end if

// now ascend up one level, so we can access data chunk
if (mmioAscend(hwav, &child, 0))
   {
   // close file
   mmioClose(hwav, 0);

   // return error, couldn't ascend
   return(-1); 	
   } // end if

// descend to the data chunk 
child.ckid = mmioFOURCC('d', 'a', 't', 'a');

if (mmioDescend(hwav, &child, &parent, MMIO_FINDCHUNK))
    {
    // close file
    mmioClose(hwav, 0);

    // return error, no data
    return(-1); 	
    } // end if

// finally!!!! now all we have to do is read the data in and
// set up the directsound buffer

// allocate the memory to load sound data
snd_buffer = (UCHAR *)malloc(child.cksize);

// read the wave data 
mmioRead(hwav, (char *)snd_buffer, child.cksize);

// close the file
mmioClose(hwav, 0);

// set rate and size in data structure
sound_fx[sound_id].rate  = wfmtx.nSamplesPerSec;
sound_fx[sound_id].size  = child.cksize;
sound_fx[sound_id].state = SOUND_LOADED;

// set up the format data structure
memset(&pcmwf, 0, sizeof(WAVEFORMATEX));

pcmwf.wFormatTag	  = WAVE_FORMAT_PCM;  // pulse code modulation
pcmwf.nChannels		  = 1;                // mono 
pcmwf.nSamplesPerSec  = 11025;            // always this rate
pcmwf.nBlockAlign	  = 1;                
pcmwf.nAvgBytesPerSec = pcmwf.nSamplesPerSec * pcmwf.nBlockAlign;
pcmwf.wBitsPerSample  = 8;
pcmwf.cbSize		  = 0;

// prepare to create sounds buffer
dsbd.dwSize			= sizeof(DSBUFFERDESC);
dsbd.dwFlags		= control_flags | DSBCAPS_STATIC | DSBCAPS_LOCSOFTWARE;
dsbd.dwBufferBytes	= child.cksize;
dsbd.lpwfxFormat	= &pcmwf;

// create the sound buffer
if (FAILED(lpds->CreateSoundBuffer(&dsbd,&sound_fx[sound_id].dsbuffer,NULL)))
   {
   // release memory
   free(snd_buffer);

   // return error
   return(-1);
   } // end if

// copy data into sound buffer
if (FAILED(sound_fx[sound_id].dsbuffer->Lock(0,					 
								      child.cksize,			
								      (void **) &audio_ptr_1, 
								      &audio_length_1,
								      (void **)&audio_ptr_2, 
								      &audio_length_2,
								      DSBLOCK_FROMWRITECURSOR)))
								 return(0);

// copy first section of circular buffer
memcpy(audio_ptr_1, snd_buffer, audio_length_1);

// copy last section of circular buffer
memcpy(audio_ptr_2, (snd_buffer+audio_length_1),audio_length_2);

// unlock the buffer
if (FAILED(sound_fx[sound_id].dsbuffer->Unlock(audio_ptr_1, 
									    audio_length_1, 
									    audio_ptr_2, 
									    audio_length_2)))
 							     return(0);

// release the temp buffer
free(snd_buffer);

// return id
return(sound_id);

} // end DSound_Load_WAV

///////////////////////////////////////////////////////////

int DSound_Replicate_Sound(int source_id)
{
// this function replicates the sent sound and sends back the
// id of the replicated sound, you would use this function
// to make multiple copies of a gunshot or something that
// you want to play multiple times simulataneously, but you
// only want to load once

if (source_id!=-1)
    {
    // duplicate the sound buffer
    // first hunt for an open id

    for (int id=0; id < MAX_SOUNDS; id++)
        {
        // is this sound open?
        if (sound_fx[id].state==SOUND_NULL)
            {
            // first make an identical copy
            sound_fx[id] = sound_fx[source_id];

            // now actually replicate the directsound buffer
            if (FAILED(lpds->DuplicateSoundBuffer(sound_fx[source_id].dsbuffer,
                                           &sound_fx[id].dsbuffer)))
                {
                // reset sound to NULL
                sound_fx[id].dsbuffer = NULL;
                sound_fx[id].state    = SOUND_NULL;

                // return error
                return(-1);
                } // end if

            // now fix up id
            sound_fx[id].id = id;
            
            // return replicated sound
            return(id);

            } // end if found
  
        } // end for id

    } // end if
else
   return(-1);
    
// else failure
return(-1);

} // end DSound_Replicate_Sound

//////////////////////////////////////////////////////////

int DSound_Init(void)
{
// this function initializes the sound system
static int first_time = 1; // used to track the first time the function
                           // is entered

// test for very first time
if (first_time)
	{		
	// clear everything out
	memset(sound_fx,0,sizeof(pcm_sound)*MAX_SOUNDS);
	
	// reset first time
	first_time = 0;

	// create a directsound object
	if (FAILED(DirectSoundCreate(NULL, &lpds, NULL)))
		return(0);

	// set cooperation level
	if (FAILED(lpds->SetCooperativeLevel((HWND)main_window_handle,DSSCL_NORMAL)))
		return(0);

	} // end if

// initialize the sound fx array
for (int index=0; index<MAX_SOUNDS; index++)
	{
	// test if this sound has been loaded
	if (sound_fx[index].dsbuffer)
		{
		// stop the sound
		sound_fx[index].dsbuffer->Stop();

		// release the buffer
		sound_fx[index].dsbuffer->Release();
	
		} // end if

	// clear the record out
	memset(&sound_fx[index],0,sizeof(pcm_sound));

	// now set up the fields
	sound_fx[index].state = SOUND_NULL;
	sound_fx[index].id    = index;

	} // end for index

// return sucess
return(1);

} // end DSound_Init

///////////////////////////////////////////////////////////

int DSound_Shutdown(void)
{
// this function releases all the memory allocated and the directsound object
// itself

// first turn all sounds off
DSound_Stop_All_Sounds();

// now release all sound buffers
for (int index=0; index<MAX_SOUNDS; index++)
	if (sound_fx[index].dsbuffer)
		sound_fx[index].dsbuffer->Release();

// now release the directsound interface itself
if (lpds)
   lpds->Release();

// return success
return(1);

} // end DSound_Shutdown

///////////////////////////////////////////////////////////

int DSound_Play(int id, int flags, int volume, int rate, int pan)
{
// this function plays a sound, the only parameter that 
// works is the flags which can be 0 to play once or
// DSBPLAY_LOOPING

if (sound_fx[id].dsbuffer)
	{
	// reset position to start
	if (FAILED(sound_fx[id].dsbuffer->SetCurrentPosition(0)))
		return(0);
	
	// play sound
	if (FAILED(sound_fx[id].dsbuffer->Play(0,0,flags)))
		return(0);
	} // end if

// return success
return(1);

} // end DSound_Play

///////////////////////////////////////////////////////////

int DSound_Set_Volume(int id,int vol)
{
// this function sets the volume on a sound 0-100

if (sound_fx[id].dsbuffer->SetVolume(DSVOLUME_TO_DB(vol))!=DS_OK)
	return(0);

// return success
return(1);

} // end DSound_Set_Volume

///////////////////////////////////////////////////////////

int DSound_Set_Freq(int id,int freq)
{
// this function sets the playback rate

if (sound_fx[id].dsbuffer->SetFrequency(freq)!=DS_OK)
	return(0);

// return success
return(1);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美电影影音先锋| 99riav一区二区三区| 亚洲精品久久久蜜桃| 日韩欧美一卡二卡| 欧美性极品少妇| 粉嫩av一区二区三区粉嫩 | 亚洲精品少妇30p| 日韩欧美不卡在线观看视频| 91在线看国产| 国产精品中文字幕一区二区三区| 午夜精品久久久久久| 亚洲欧美另类久久久精品2019| 欧美不卡一二三| 国产一区二区日韩精品| 香蕉成人啪国产精品视频综合网| 欧美激情综合网| 精品乱人伦小说| 在线综合视频播放| 欧美日韩视频在线第一区| 不卡一区二区中文字幕| 国产精品亚洲成人| 国产一区二区精品久久91| 美女久久久精品| 日韩精品一二三区| 亚洲va欧美va人人爽午夜 | 性感美女久久精品| 亚洲夂夂婷婷色拍ww47| 亚洲免费观看高清完整版在线 | 一本色道**综合亚洲精品蜜桃冫| 成人激情校园春色| 国产福利精品一区二区| 国产高清精品在线| 国产精品一品视频| 国产成人一级电影| 成人污污视频在线观看| 国产91色综合久久免费分享| 国产资源在线一区| 国产精品99精品久久免费| 韩国av一区二区三区在线观看| 久久精品国产第一区二区三区| 日韩国产欧美在线播放| 免费观看30秒视频久久| 麻豆高清免费国产一区| 激情国产一区二区| 国产精品中文字幕日韩精品| 国产ts人妖一区二区| 成人午夜私人影院| 一本一本久久a久久精品综合麻豆| 99re6这里只有精品视频在线观看| 成人午夜激情在线| 色综合久久天天| 91九色02白丝porn| 欧美日韩一区二区在线观看| 欧美久久久久久久久久| 91精品国产乱| 2024国产精品| 国产亚洲制服色| 一区在线播放视频| 夜夜嗨av一区二区三区中文字幕| 亚洲精品伦理在线| 日韩精品一卡二卡三卡四卡无卡| 日本成人在线电影网| 国产一区二三区好的| www.欧美精品一二区| 欧美在线不卡一区| 日韩亚洲国产中文字幕欧美| 久久精品人人做人人综合| ...av二区三区久久精品| 亚洲一区二区三区在线看| 日本午夜一区二区| 国产电影一区在线| 91久久精品一区二区二区| 日韩视频在线一区二区| 久久精品欧美日韩精品 | 亚洲免费视频中文字幕| 日日欢夜夜爽一区| 国产一区二区精品久久91| 97se亚洲国产综合自在线观| 欧美一区二区网站| 国产精品色婷婷久久58| 亚欧色一区w666天堂| 国产一区美女在线| 欧美日韩综合在线| 久久九九久精品国产免费直播| 亚洲主播在线播放| 国产精华液一区二区三区| 欧美三级日本三级少妇99| 精品成人私密视频| 亚洲福利视频导航| 成人ar影院免费观看视频| 日韩一级大片在线| 亚洲最新视频在线观看| 国产mv日韩mv欧美| 日韩一区二区三区四区| 亚洲精品亚洲人成人网| 国产精品一二一区| 欧美一级爆毛片| 亚洲国产另类av| 99热精品一区二区| 久久嫩草精品久久久精品| 婷婷综合另类小说色区| 99久久综合色| 久久免费视频色| 蜜臂av日日欢夜夜爽一区| av亚洲精华国产精华精华| 欧美大黄免费观看| 欧美激情在线一区二区| 免费观看日韩av| 91久久香蕉国产日韩欧美9色| 精品嫩草影院久久| 亚洲婷婷在线视频| 国内偷窥港台综合视频在线播放| 欧洲视频一区二区| 国产欧美日韩卡一| 免费看黄色91| 99久久精品免费精品国产| 久久久精品天堂| 五月天激情综合网| 色呦呦国产精品| 337p日本欧洲亚洲大胆精品| 国产精品国产自产拍高清av| 国产精品一区二区三区网站| 欧美一区日本一区韩国一区| 国产精品久久久久久久第一福利 | 91精品国产欧美日韩| 久久婷婷国产综合国色天香| 全国精品久久少妇| 欧美优质美女网站| 久久久99精品久久| 日本aⅴ精品一区二区三区| 欧美视频一区二区在线观看| 亚洲欧洲精品一区二区精品久久久 | 一区二区三区四区在线播放| 国产91精品一区二区| 精品国产免费一区二区三区四区| 婷婷中文字幕综合| 在线影院国内精品| 亚洲精选视频免费看| 91在线免费播放| 国产精品久久久久久久久晋中| thepron国产精品| 中文字幕精品一区| 粉嫩久久99精品久久久久久夜| 日韩精品一区二区三区在线播放 | 天天色 色综合| 在线免费观看日韩欧美| 亚洲日本在线看| 99精品视频在线观看| 国产欧美一区二区精品婷婷| 不卡高清视频专区| 亚洲天堂精品视频| 99国产精品99久久久久久| 国产精品二区一区二区aⅴ污介绍| 久久99最新地址| 国产视频911| 成人一区二区三区视频在线观看 | 国产精品一区二区男女羞羞无遮挡 | 日本国产一区二区| 亚洲已满18点击进入久久| 欧美无砖专区一中文字| 午夜精品福利一区二区三区av | 欧美日韩一区小说| 亚洲高清免费一级二级三级| 欧美日韩一级大片网址| 日韩成人一级大片| 精品国产人成亚洲区| 国产.欧美.日韩| 日韩理论片中文av| 欧美三级蜜桃2在线观看| 精品一二三四在线| 欧美韩日一区二区三区四区| 99久久er热在这里只有精品66| 自拍偷在线精品自拍偷无码专区| 色婷婷国产精品综合在线观看| 蜜桃视频在线观看一区二区| 久久日韩粉嫩一区二区三区| 成人av在线一区二区| 一区二区三区日韩欧美精品| 日韩一区二区中文字幕| 国产成人亚洲综合色影视 | 有坂深雪av一区二区精品| 911精品国产一区二区在线| 精品无人码麻豆乱码1区2区 | 男女性色大片免费观看一区二区| 久久亚洲一区二区三区四区| 蜜臀久久99精品久久久画质超高清| 亚洲国产高清在线观看视频| 在线欧美小视频| 久久成人免费日本黄色| 中文一区在线播放| 91无套直看片红桃| 国产一区二区三区不卡在线观看| 亚洲人快播电影网| 日韩女优av电影| 91在线视频在线| 婷婷综合五月天| 国产精品丝袜在线| 欧美精品色综合| 国产不卡在线视频| 亚洲色图在线视频|