91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

本工程包含了使用各種API(Direct3D,OpenGL,GDI,DirectSound,SDL2)播放多媒體例子。 其中音頻輸入為PCM采樣數據。輸出至系統的聲卡播放出來。 視頻輸入為YUV/RGB像素數據。輸出至顯示器上的一個窗口播放出來。 通過本工程的代碼初學者可以快速學習使用這幾個API播放視頻和音頻的技術。 一共包括了如下幾個子工程: simplest_audio_play_directsound: 使用DirectSound播放PCM音頻采樣數據。 simplest_audio_play_sdl2: 使用SDL2播放PCM音頻采樣數據。 simplest_video_play_direct3d: 使用Direct3D的Surface播放RGB/YUV視頻像素數據。 simplest_video_play_direct3d_texture:使用Direct3D的Texture播放RGB視頻像素數據。 simplest_video_play_gdi: 使用GDI播放RGB/YUV視頻像素數據。 simplest_video_play_opengl: 使用OpenGL播放RGB/YUV視頻像素數據。 simplest_video_play_opengl_texture: 使用OpenGL的Texture播放YUV視頻像素數據。 simplest_video_play_sdl2: 使用SDL2播放RGB/YUV視頻像素數據。

資源截圖

代碼片段和文件信息

/**
?*?最簡單的DirectSound播放音頻的例子(DirectSound播放PCM)
?*?Simplest?Audio?Play?DirectSound?(DirectSound?play?PCM)?
?*
?*?雷霄驊?Lei?Xiaohua
?*?leixiaohua1020@126.com
?*?中國傳媒大學/數字電視技術
?*?Communication?University?of?China?/?Digital?TV?Technology
?*?http://blog.csdn.net/leixiaohua1020
?*
?*?本程序使用DirectSound播放PCM音頻采樣數據。
?*?是最簡單的DirectSound播放音頻的教程。
?*
?*?函數調用步驟如下:
?*
?*?[初始化]
?*?DirectSoundCreate8():創建一個DirectSound對象。
?*?SetCooperativeLevel():設置協作權限,不然沒有聲音。
?*?IDirectSound8->CreateSoundBuffer():創建一個主緩沖區對象。
?*?IDirectSoundBuffer->QueryInterface(IID_IDirectSoundBuffer8..):
?* 創建一個副緩沖區對象,用來存儲要播放的聲音數據文件。
?*?IDirectSoundBuffer8->QueryInterface(IID_IDirectSoundNotify..):
?* 創建通知對象,通知應用程序指定播放位置已經達到。
?*?IDirectSoundNotify8->SetNotificationPositions():設置通知位置。
?*?IDirectSoundBuffer8->SetCurrentPosition():設置播放的起始點。
?*?IDirectSoundBuffer8->Play():開始播放。
?*
?*?[循環播放數據]
?*?IDirectSoundBuffer8->Lock():鎖定副緩沖區,準備寫入數據。
?*?fread():讀取數據。
?*?IDirectSoundBuffer8->Unlock():解鎖副緩沖區。
?*?WaitForMultipleobjects():等待“播放位置已經達到”的通知。
?*
?*?This?software?plays?PCM?raw?audio?data?using?DirectSound.
?*?It‘s?the?simplest?tutorial?about?DirectSound.
?*
?*?The?process?is?shown?as?follows:
?*
?*?[Init]
?*?DirectSoundCreate8():?Init?DirectSound?object.
?*?SetCooperativeLevel():?Must?set?or?we?won‘t?hear?sound.
?*?IDirectSound8->CreateSoundBuffer():?Create?primary?sound?buffer.
?*?IDirectSoundBuffer->QueryInterface(IID_IDirectSoundBuffer8..):?
?* Create?secondary?sound?buffer.
?*?IDirectSoundBuffer8->QueryInterface(IID_IDirectSoundNotify..):?
?* Create?Notification?object.
?*?IDirectSoundNotify8->SetNotificationPositions():
?* Set?Notification?Positions.
?*?IDirectSoundBuffer8->SetCurrentPosition():?Set?position?to?start.
?*?IDirectSoundBuffer8->Play():?Begin?to?play.
?*
?*?[Loop?to?play?data]
?*?IDirectSoundBuffer8->Lock():?Lock?secondary?buffer.
?*?fread():?get?PCM?data.
?*?IDirectSoundBuffer8->Unlock():?UnLock?secondary?buffer.
?*?WaitForMultipleobjects():?Wait?for?Notifications.
?*/
#include?
#include?
#include?
#include?


#define?MAX_AUDIO_BUF?4?
#define?BUFFERNOTIFYSIZE?192000?


int?sample_rate=44100; //PCM?sample?rate
int?channels=2; //PCM?channel?number
int?bits_per_sample=16; //bits?per?sample

BOOL?main(int?argcchar?*?argv[])
{
int?i;
FILE?*?fp;
if((fp=fopen(“../NocturneNo2inEflat_44.1k_s16le.pcm““rb“))==NULL){
printf(“cannot?open?this?file\n“);
return?-1;
}

IDirectSound8?*m_pDS=0;
IDirectSoundBuffer8?*m_pDSBuffer8=NULL; //used?to?manage?sound?buffers.
IDirectSoundBuffer?*m_pDSBuffer=NULL;
IDirectSoundNotify8?*m_pDSNotify=0;
DSBPOSITIONNOTIFY?m_pDSPosNotify[MAX_AUDIO_BUF];
HANDLE?m_event[MAX_AUDIO_BUF];

SetConsoletitle(TEXT(“Simplest?Audio?Play?DirectSound“));//Console?title
//Init?DirectSound
if(FAILED(DirectSoundCreate8(NULL&m_pDSNULL)))
return?FALSE;
if(FAILED(m_pDS->SetCooperativeLevel(FindWindow(NULLTEXT(“Simpl

評論

共有 條評論