/****************************************************************************
*
* AUDIO.C
*
* Simple routines to play audio using an AVIStream to get data.
*
* Uses global variables, so only one instance at a time.
* (Usually, there's only one sound card, so this isn't so bad.
*
**************************************************************************/
/**************************************************************************
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
* PURPOSE.
*
* Copyright (c) 1992, 1993 Microsoft Corporation. All Rights Reserved.
*
**************************************************************************/
#include "strbasic.h"
#ifdef WIN95STUFF
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>
#include <vfw.h>
#include "udmIA64.h"
// WIN64 Cleanup: Shuler
// Until the Unified Data Model is complete and
// available in MSVC++ 7.0, this header file is
// required.
#include "audio.h"
#include "muldived.h"
/*--------------------------------------------------------------+
| ****************** AUDIO PLAYING SUPPORT ******************** |
+--------------------------------------------------------------*/
static HWAVEOUT shWaveOut = 0; /* Current MCI device ID */
static LONG slBegin;
static LONG slWaveBegin;
static LONG slCurrent;
static LONG slEnd;
static LONG slWaveEnd;
static BOOL sfLooping;
static BOOL sfPlaying = FALSE;
static LONG sTotal;
static LONG sPlayed;
#define MAX_AUDIO_BUFFERS 16
#define MIN_AUDIO_BUFFERS 2
#define AUDIO_BUFFER_SIZE 16384
static WORD swBuffers; // total # buffers
static WORD swBuffersOut; // buffers device has
static WORD swNextBuffer; // next buffer to fill
static LPWAVEHDR salpAudioBuf[MAX_AUDIO_BUFFERS];
static PAVISTREAM spavi; // stream we're playing
static LONG slSampleSize; // size of an audio sample
static LONG sdwBytesPerSec;
static LONG sdwSamplesPerSec;
//watje ranges at where the sound will be played
//these are percentages based ver the current time segment
static float startRange;
static float endRange;
/*---------------------------------------------------------------+
| aviaudioCloseDevice -- close the open audio device, if any. |
+---------------------------------------------------------------*/
void NEAR aviaudioCloseDevice(void)
{
WORD w;
if (shWaveOut) {
while (swBuffers > 0) {
--swBuffers;
waveOutUnprepareHeader(shWaveOut, salpAudioBuf[swBuffers],
sizeof(WAVEHDR));
GlobalFreePtr((LPSTR) salpAudioBuf[swBuffers]);
}
w = waveOutClose(shWaveOut);
shWaveOut = NULL;
}
}
/*--------------------------------------------------------------+
| aviaudioOpenDevice -- get ready to play waveform data. |
+--------------------------------------------------------------*/
BOOL FAR aviaudioOpenDevice(HWND hwnd, PAVISTREAM pavi)
{
WORD w;
LPVOID lpFormat;
LONG cbFormat;
AVISTREAMINFO strhdr;
if (!pavi) // no wave data to play
return FALSE;
if (shWaveOut) // already something playing
return TRUE;
spavi = pavi;
AVIStreamInfo(pavi, &strhdr, sizeof(strhdr));
slSampleSize = (LONG) strhdr.dwSampleSize;
if (slSampleSize <= 0 || slSampleSize > AUDIO_BUFFER_SIZE)
return FALSE;
AVIStreamFormatSize(pavi, 0, &cbFormat);
lpFormat = GlobalAllocPtr(GHND, cbFormat);
if (!lpFormat)
return FALSE;
AVIStreamReadFormat(pavi, 0, lpFormat, &cbFormat);
sdwSamplesPerSec = ((LPWAVEFORMAT) lpFormat)->nSamplesPerSec;
sdwBytesPerSec = ((LPWAVEFORMAT) lpFormat)->nAvgBytesPerSec;
w = waveOutOpen(&shWaveOut, (UINT)WAVE_MAPPER, lpFormat,
(DWORD_PTR) hwnd, 0L, CALLBACK_WINDOW);
// WIN64 Cleanup: Shuler
//
// Maybe we failed because someone is playing sound already.
// Shut any sound off, and try once more before giving up.
//
if (w) {
sndPlaySound(NULL, 0);
w = waveOutOpen(&shWaveOut, (UINT)WAVE_MAPPER, lpFormat,
(DWORD_PTR)hwnd, 0L, CALLBACK_WINDOW);
// WIN64 Cleanup: Shuler
}
if (w != 0) {
/* Show error message here? */
return FALSE;
}
for (swBuffers = 0; swBuffers < MAX_AUDIO_BUFFERS; swBuffers++) {
if (!(salpAudioBuf[swBuffers] =
(LPWAVEHDR)GlobalAllocPtr(GMEM_MOVEABLE | GMEM_SHARE,
(DWORD)(sizeof(WAVEHDR) + AUDIO_BUFFER_SIZE))))
break;
salpAudioBuf[swBuffers]->dwFlags = WHDR_DONE;
salpAudioBuf[swBuffers]->lpData = (LPSTR) salpAudioBuf[swBuffers]
+ sizeof(WAVEHDR);
salpAudioBuf[swBuffers]->dwBufferLength = AUDIO_BUFFER_SIZE;
if (!waveOutPrepareHeader(shWaveOut, salpAudioBuf[swBuffers],
sizeof(WAVEHDR)))
continue;
GlobalFreePtr((LPSTR) salpAudioBuf[swBuffers]);
break;
}
if (swBuffers < MIN_AUDIO_BUFFERS) {
aviaudioCloseDevice();
return FALSE;
}
swBuffersOut = 0;
swNextBuffer = 0;
sfPlaying = FALSE;
return TRUE;
}
/*--------------------------------------------------------------+
| aviaudioTime - |
| Return the time in milliseconds corresponding to the |
| currently playing audio sample, or -1 if no audio is playing. |
| |
| WARNING: Some sound cards are pretty inaccurate! |
+--------------------------------------------------------------*/
LONG FAR aviaudioTime(void)
{
MMTIME mmtime;
if (!sfPlaying)
return -1;
mmtime.wType = TIME_SAMPLES;
waveOutGetPosition(shWaveOut, &mmtime, sizeof(mmtime));
if (mmtime.wType == TIME_SAMPLES)
return AVIStreamSampleToTime(spavi, slBegin)
+ muldiv32(mmtime.u.sample, 1000, sdwSamplesPerSec);
else if (mmtime.wType == TIME_BYTES)
return AVIStreamSampleToTime(spavi, slBegin)
+ muldiv32(mmtime.u.cb, 1000, sdwBytesPerSec);
else
return -1;
}
/*--------------------------------------------------------------+
| aviaudioiFillBuffers - |
| Fill up any empty audio buffers and ship them out to the |
| device. |
+--------------------------------------------------------------*/
BOOL NEAR aviaudioiFillBuffers(void)
{
LONG lRead;
WORD w;
LONG lSamplesToPlay;
int i, sti;
float perStart,perEnd;
float per;
/* We're not playing, so do nothing. */
if (!sfPlaying)
return TRUE;
while (swBuffersOut < swBuffers) {
if (sPlayed >= sTotal) {
if (sfLooping) {
/* Looping, so go to the beginning. */
slCurrent = slBegin;
sPlayed = 0;
} else {
break;
}
}
if (slCurrent >= slWaveEnd) {
slCurrent = slWaveBegin;
}
/* Figure out how much data should go in this buffer */
lSamplesToPlay = slWaveEnd - slCurrent;
if (lSamplesToPlay + sPlayed > sTotal) {
lSamplesToPlay = sTotal - sPlayed;
}
if (lSamplesToPlay > AUDIO_BUFFER_SIZE / slSampleSize)
lSamplesToPlay = AUDIO_BUFFER_SIZE / slSampleSize;
AVIStreamRead(spavi, slCurrent, lSamplesToPlay,
salpAudioBuf[swNextBuffer]->lpData,
AUDIO_BUFFER_SIZE,
&salpAudioBuf[swNextBuffer]->dwBufferLength,
&lRead);
if (lRead != lSamplesToPlay) {
return FALSE;
}
perStart = (float)sPlayed/(float)sTotal;
perEnd = (float)(sPlayed+lRead)/(float)sTotal;
//watje if the current time segment of the cache falls outside the range then nuke
if ( (perEnd < startRange) || (perStart > endRange) )
{
for (i=0; i < lRead; i++)
salpAudioBuf[swNextBuffer]->lpData[i] = 0;
}
//watje if the current end segment of the cache falls inside the range then nuke just part of the cache
else if ( (perEnd >= startRange
没有合适的资源?快使用搜索试试~ 我知道了~
max sdk 下载。
共1133个文件
h:729个
cpp:159个
vcproj:45个
5星 · 超过95%的资源 需积分: 9 141 下载量 11 浏览量
2009-11-25
19:57:42
上传
评论
收藏 9.1MB RAR 举报
温馨提示
把 lib 和 include 都加到VC的目录里, 注意: 按howto\3dsmaxPluginWizard把sdk集成到vs里。 里面的工程都是VC2005的,vc2008也可以编译,但是vc2003我没试过~ 编译时选用Release方式,编出的插件在plugin目录里。 将编出的插件放到Autodesk\3ds Max 9\plugins里,就可以在打开3ds max9时使用插件了~
资源推荐
资源详情
资源评论
收起资源包目录
max sdk 下载。 (1133个子文件)
3dsmaxPluginWizard.vsz.bak 171B
cuitest_24a.bmp 5KB
cuitest_24i.bmp 5KB
bmp00002.bmp 4KB
mask_dis.bmp 4KB
imagemsk.bmp 2KB
ccimage.bmp 2KB
cuitest_16a.bmp 2KB
cuitest_16i.bmp 2KB
uitools.bmp 2KB
toolbar1.bmp 1KB
tb.bmp 1KB
tbmask.bmp 1KB
ccflyoff.bmp 838B
tbarmask.bmp 838B
toolbar.bmp 838B
ccflymsk.bmp 694B
ccflyimg.bmp 694B
picknode.bmp 358B
toolmask.bmp 122B
map_pick.bmp 122B
audio.c 12KB
ICoordSys_i.c 3KB
index.chm 96KB
notify.clw 2KB
import.cpp 59KB
xgsphere.cpp 44KB
EditFaceData.cpp 40KB
refcheck.cpp 40KB
triobj.cpp 37KB
soundobj.cpp 36KB
tmattest.cpp 35KB
cjrender.cpp 34KB
xrefutil.cpp 33KB
formation.cpp 31KB
custctrl.cpp 31KB
simpobj.cpp 30KB
SHADER_TYPE_Shader.cpp 29KB
fog.cpp 28KB
simpmod.cpp 24KB
bendmod.cpp 24KB
footstep.cpp 23KB
ccutil.cpp 22KB
mrGeomShaderObject.cpp 21KB
scontext.cpp 20KB
raytrace.cpp 17KB
sound.cpp 17KB
TestMod.cpp 17KB
PainterTester.cpp 16KB
StackBossMod.cpp 15KB
mrTwoSidedShader.cpp 14KB
SineWave.cpp 14KB
tester.cpp 14KB
PainterTextureSample.cpp 14KB
SampleATSProvider.cpp 13KB
ColorFaceData.cpp 13KB
bendmanip.cpp 13KB
glow.cpp 13KB
SPACE_WARP_TYPE_SimpleWSMMod.cpp 12KB
PhyExportSample.cpp 12KB
xmodifier.cpp 12KB
StackBoss.cpp 11KB
pursuit.cpp 11KB
MATERIAL_TYPE_Mtl.cpp 11KB
dynpblock.cpp 11KB
Widget.cpp 10KB
PaintDeformTest.cpp 10KB
MODIFIER_TYPE_Modifier.cpp 10KB
scp_read.cpp 10KB
SKIN_GIZMO_TYPE_GizmoClass.cpp 10KB
sampleeff.cpp 9KB
PROCEDURAL_OBJECT_TYPE_GeomObject.cpp 9KB
sphere.cpp 9KB
cuitest.cpp 9KB
cjrui.cpp 9KB
MANIP_TYPE_Manipulator.cpp 9KB
objimp.cpp 9KB
testLayerA.cpp 9KB
TEXTURE_2D_TYPE_Texmap.cpp 8KB
MODIFIER_TYPE_SimpleMod2.cpp 8KB
doexport.cpp 8KB
nodetrak.cpp 8KB
PainterTextureSamplePainterInterface.cpp 8KB
RandomFaceData.cpp 8KB
asciiimp.cpp 7KB
TEXTURE_3D_TYPE_Tex3D.cpp 7KB
TEXTURE_3D_TYPE_Texmap.cpp 7KB
mrShaderFilter.cpp 7KB
COLPICK_TYPE_ColPick.cpp 7KB
instance.cpp 7KB
PROCEDURAL_OBJECT_TYPE_SimpleObject2.cpp 7KB
ATMOSPHERIC_TYPE_Atmospheric.cpp 7KB
notifdlg.cpp 7KB
FILTER_KERNEL_TYPE_FilterKernel.cpp 6KB
dlxclass.cpp 6KB
SHADOW_TYPE_ShadowType.cpp 6KB
MANIP_TYPE_SimpleManipulator.cpp 6KB
lights.cpp 6KB
customvdata.cpp 6KB
rendutil.cpp 6KB
共 1133 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
- wangjunjingqq27727822018-11-28不是我所要的
- subaozhen2014-05-06东西很不错 超赞 谢谢分享
- siwenbailei20022013-03-18可用,非常感谢!
- qq7451256842013-05-18真的可用,谢谢了~~~
BillHsu1024
- 粉丝: 24
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功