axmol/CocosDenshion/third_party/fmod/examples/dsp_effectperspeaker/main.c

269 lines
8.6 KiB
C
Raw Normal View History

modified: cocos2dx/.cproject modified: cocos2dx/CCConfiguration.cpp modified: cocos2dx/CCConfiguration.h modified: cocos2dx/actions/CCActionGrid3D.cpp modified: cocos2dx/platform/Linux/CCAplication_linux.cpp modified: cocos2dx/platform/Linux/CCAplication_linux.h modified: cocos2dx/platform/Linux/CCImage_Linux.cpp modified: mycreate-android-project.sh new file: post.sh modified: template/android/mycopy_files.sh modified: tests/AppDelegate.cpp new file: tests/test.linux/Res deleted: tests/test.linux/Res/Hello.png deleted: tests/test.linux/Res/Images/BoilingFoam.plist deleted: tests/test.linux/Res/Images/BurstPipe.plist deleted: tests/test.linux/Res/Images/Comet.plist deleted: tests/test.linux/Res/Images/Comet.png deleted: tests/test.linux/Res/Images/ExplodingRing.plist deleted: tests/test.linux/Res/Images/Flower.plist deleted: tests/test.linux/Res/Images/Fog.png deleted: tests/test.linux/Res/Images/Galaxy.plist deleted: tests/test.linux/Res/Images/HelloWorld.png deleted: tests/test.linux/Res/Images/Icon.png deleted: tests/test.linux/Res/Images/LavaFlow.plist deleted: tests/test.linux/Res/Images/Pea.png deleted: tests/test.linux/Res/Images/Phoenix.plist deleted: tests/test.linux/Res/Images/PlanetCute-1024x1024.png deleted: tests/test.linux/Res/Images/SendScoreButton.png deleted: tests/test.linux/Res/Images/SendScoreButtonPressed.png deleted: tests/test.linux/Res/Images/SpinningPeas.plist deleted: tests/test.linux/Res/Images/SpinningPeas.png deleted: tests/test.linux/Res/Images/Spiral.plist deleted: tests/test.linux/Res/Images/SpookyPeas.plist deleted: tests/test.linux/Res/Images/SpookyPeas.png deleted: tests/test.linux/Res/Images/Upsidedown.plist deleted: tests/test.linux/Res/Images/atlastest.png deleted: tests/test.linux/Res/Images/b1-hd.png deleted: tests/test.linux/Res/Images/b1.png deleted: tests/test.linux/Res/Images/b2-hd.png deleted: tests/test.linux/Res/Images/b2.png deleted: tests/test.linux/Res/Images/background.png deleted: tests/test.linux/Res/Images/background1-hd.png deleted: tests/test.linux/Res/Images/background1.png deleted: tests/test.linux/Res/Images/background2-hd.png deleted: tests/test.linux/Res/Images/background2.png deleted: tests/test.linux/Res/Images/background3-hd.png deleted: tests/test.linux/Res/Images/background3.png deleted: tests/test.linux/Res/Images/ball-hd.png deleted: tests/test.linux/Res/Images/ball.png deleted: tests/test.linux/Res/Images/bitmapFontTest3.fnt deleted: tests/test.linux/Res/Images/bitmapFontTest3.png deleted: tests/test.linux/Res/Images/blocks-hd.png deleted: tests/test.linux/Res/Images/blocks.png deleted: tests/test.linux/Res/Images/btn-about-normal.png deleted: tests/test.linux/Res/Images/btn-about-selected.png deleted: tests/test.linux/Res/Images/btn-highscores-normal.png deleted: tests/test.linux/Res/Images/btn-highscores-selected.png deleted: tests/test.linux/Res/Images/btn-play-normal.png deleted: tests/test.linux/Res/Images/btn-play-selected.png deleted: tests/test.linux/Res/Images/bugs/RetinaDisplay.jpg deleted: tests/test.linux/Res/Images/bugs/bug886.jpg deleted: tests/test.linux/Res/Images/bugs/bug886.png deleted: tests/test.linux/Res/Images/bugs/circle-hd.plist deleted: tests/test.linux/Res/Images/bugs/circle-hd.png deleted: tests/test.linux/Res/Images/bugs/circle.plist deleted: tests/test.linux/Res/Images/bugs/circle.png deleted: tests/test.linux/Res/Images/bugs/corner.png deleted: tests/test.linux/Res/Images/bugs/edge.png deleted: tests/test.linux/Res/Images/bugs/fill.png deleted: tests/test.linux/Res/Images/bugs/picture-hd.png deleted: tests/test.linux/Res/Images/bugs/picture.png deleted: tests/test.linux/Res/Images/close-hd.png deleted: tests/test.linux/Res/Images/close.png deleted: tests/test.linux/Res/Images/debian.plist deleted: tests/test.linux/Res/Images/f1-hd.png deleted: tests/test.linux/Res/Images/f1.png deleted: tests/test.linux/Res/Images/f2-hd.png deleted: tests/test.linux/Res/Images/f2.png deleted: tests/test.linux/Res/Images/fire-grayscale.png deleted: tests/test.linux/Res/Images/fire.png deleted: tests/test.linux/Res/Images/fps_images.png deleted: tests/test.linux/Res/Images/grossini-hd.png deleted: tests/test.linux/Res/Images/grossini.png deleted: tests/test.linux/Res/Images/grossini_128x256_mipmap.pvr deleted: tests/test.linux/Res/Images/grossini_dance_01.png deleted: tests/test.linux/Res/Images/grossini_dance_02.png deleted: tests/test.linux/Res/Images/grossini_dance_03.png deleted: tests/test.linux/Res/Images/grossini_dance_04.png deleted: tests/test.linux/Res/Images/grossini_dance_05.png deleted: tests/test.linux/Res/Images/grossini_dance_06.png deleted: tests/test.linux/Res/Images/grossini_dance_07.png deleted: tests/test.linux/Res/Images/grossini_dance_08.png deleted: tests/test.linux/Res/Images/grossini_dance_09.png deleted: tests/test.linux/Res/Images/grossini_dance_10.png deleted: tests/test.linux/Res/Images/grossini_dance_11.png deleted: tests/test.linux/Res/Images/grossini_dance_12.png deleted: tests/test.linux/Res/Images/grossini_dance_13.png deleted: tests/test.linux/Res/Images/grossini_dance_14.png deleted: tests/test.linux/Res/Images/grossini_dance_atlas-hd.png deleted: tests/test.linux/Res/Images/grossini_dance_atlas-mono.png deleted: tests/test.linux/Res/Images/grossini_dance_atlas.png deleted: tests/test.linux/Res/Images/grossini_dance_atlas_nomipmap.png deleted: tests/test.linux/Res/Images/grossini_pvr_rgba4444.pvr deleted: tests/test.linux/Res/Images/grossini_pvr_rgba8888.pvr deleted: tests/test.linux/Res/Images/grossinis_sister1-hd.png deleted: tests/test.linux/Res/Images/grossinis_sister1-testalpha.png deleted: tests/test.linux/Res/Images/grossinis_sister1-testalpha.ppng deleted: tests/test.linux/Res/Images/grossinis_sister1.png deleted: tests/test.linux/Res/Images/grossinis_sister2-hd.png deleted: tests/test.linux/Res/Images/grossinis_sister2.png deleted: tests/test.linux/Res/Images/landscape-1024x1024.png deleted: tests/test.linux/Res/Images/logo-mipmap.pvr deleted: tests/test.linux/Res/Images/logo-nomipmap.pvr deleted: tests/test.linux/Res/Images/menuitemsprite.png deleted: tests/test.linux/Res/Images/paddle-hd.png deleted: tests/test.linux/Res/Images/paddle.png deleted: tests/test.linux/Res/Images/particles-hd.png deleted: tests/test.linux/Res/Images/particles.png deleted: tests/test.linux/Res/Images/pattern1.png deleted: tests/test.linux/Res/Images/piece.png deleted: tests/test.linux/Res/Images/powered.png deleted: tests/test.linux/Res/Images/r1-hd.png deleted: tests/test.linux/Res/Images/r1.png deleted: tests/test.linux/Res/Images/r2-hd.png deleted: tests/test.linux/Res/Images/r2.png deleted: tests/test.linux/Res/Images/snow.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-0-0.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-0-1.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-0-2.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-0-3.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-0-4.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-0-5.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-0-6.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-0-7.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-1-0.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-1-1.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-1-2.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-1-3.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-1-4.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-1-5.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-1-6.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-1-7.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-2-0.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-2-1.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-2-2.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-2-3.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-2-4.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-2-5.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-2-6.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-2-7.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-3-0.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-3-1.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-3-2.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-3-3.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-3-4.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-3-5.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-3-6.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-3-7.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-4-0.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-4-1.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-4-2.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-4-3.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-4-4.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-4-5.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-4-6.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-4-7.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-5-0.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-5-1.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-5-2.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-5-3.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-5-4.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-5-5.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-5-6.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-5-7.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-6-0.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-6-1.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-6-2.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-6-3.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-6-4.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-6-5.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-6-6.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-6-7.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-7-0.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-7-1.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-7-2.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-7-3.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-7-4.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-7-5.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-7-6.png deleted: tests/test.linux/Res/Images/sprites_test/sprite-7-7.png deleted: tests/test.linux/Res/Images/spritesheet1.png deleted: tests/test.linux/Res/Images/stars-grayscale.png deleted: tests/test.linux/Res/Images/stars.png deleted: tests/test.linux/Res/Images/stars2-grayscale.png deleted: tests/test.linux/Res/Images/stars2.png deleted: tests/test.linux/Res/Images/streak.png deleted: tests/test.linux/Res/Images/test-rgba1.png deleted: tests/test.linux/Res/Images/test_blend.png deleted: tests/test.linux/Res/Images/test_image-bad_encoding.pvr deleted: tests/test.linux/Res/Images/test_image.jpeg deleted: tests/test.linux/Res/Images/test_image.png deleted: tests/test.linux/Res/Images/test_image.pvr deleted: tests/test.linux/Res/Images/test_image.pvrraw deleted: tests/test.linux/Res/Images/test_image_a8.pvr deleted: tests/test.linux/Res/Images/test_image_ai88.pvr deleted: tests/test.linux/Res/Images/test_image_bgra8888.pvr deleted: tests/test.linux/Res/Images/test_image_i8.pvr deleted: tests/test.linux/Res/Images/test_image_pvrtc2bpp.pvr deleted: tests/test.linux/Res/Images/test_image_pvrtc4bpp.pvr deleted: tests/test.linux/Res/Images/test_image_rgb565.pvr deleted: tests/test.linux/Res/Images/test_image_rgba4444.pvr deleted: tests/test.linux/Res/Images/test_image_rgba4444.pvr.ccz deleted: tests/test.linux/Res/Images/test_image_rgba4444.pvr.gz deleted: tests/test.linux/Res/Images/test_image_rgba4444_mipmap.pvr deleted: tests/test.linux/Res/Images/test_image_rgba5551.pvr deleted: tests/test.linux/Res/Images/test_image_rgba8888.pvr deleted: tests/test.linux/Res/Images/texture1024x1024.png deleted: tests/test.linux/Res/Images/texture2048x2048.png deleted: tests/test.linux/Res/Images/texture512x512.png deleted: tests/test.linux/Res/TileMaps/fixed-ortho-test2.png deleted: tests/test.linux/Res/TileMaps/hexa-test.tmx deleted: tests/test.linux/Res/TileMaps/hexa-tiles.png deleted: tests/test.linux/Res/TileMaps/iso-test-bug787.tmx deleted: tests/test.linux/Res/TileMaps/iso-test-movelayer.tmx deleted: tests/test.linux/Res/TileMaps/iso-test-objectgroup.tmx deleted: tests/test.linux/Res/TileMaps/iso-test-vertexz.tmx deleted: tests/test.linux/Res/TileMaps/iso-test-zorder.tmx deleted: tests/test.linux/Res/TileMaps/iso-test.png deleted: tests/test.linux/Res/TileMaps/iso-test.tmx deleted: tests/test.linux/Res/TileMaps/iso-test1.tmx deleted: tests/test.linux/Res/TileMaps/iso-test2-uncompressed.tmx deleted: tests/test.linux/Res/TileMaps/iso-test2.png deleted: tests/test.linux/Res/TileMaps/iso-test2.tmx deleted: tests/test.linux/Res/TileMaps/iso.png deleted: tests/test.linux/Res/TileMaps/levelmap.tga deleted: tests/test.linux/Res/TileMaps/ortho-objects.tmx deleted: tests/test.linux/Res/TileMaps/ortho-test1.png deleted: tests/test.linux/Res/TileMaps/ortho-test1_bw.png deleted: tests/test.linux/Res/TileMaps/ortho-test2.png deleted: tests/test.linux/Res/TileMaps/orthogonal-test-movelayer.tmx deleted: tests/test.linux/Res/TileMaps/orthogonal-test-vertexz.tmx deleted: tests/test.linux/Res/TileMaps/orthogonal-test-zorder.tmx deleted: tests/test.linux/Res/TileMaps/orthogonal-test1.tmx deleted: tests/test.linux/Res/TileMaps/orthogonal-test1.tsx deleted: tests/test.linux/Res/TileMaps/orthogonal-test2.tmx deleted: tests/test.linux/Res/TileMaps/orthogonal-test3.tmx deleted: tests/test.linux/Res/TileMaps/orthogonal-test4-hd.tmx deleted: tests/test.linux/Res/TileMaps/orthogonal-test4.tmx deleted: tests/test.linux/Res/TileMaps/orthogonal-test5.tmx deleted: tests/test.linux/Res/TileMaps/orthogonal-test6-hd.tmx deleted: tests/test.linux/Res/TileMaps/orthogonal-test6.tmx deleted: tests/test.linux/Res/TileMaps/test-object-layer.tmx deleted: tests/test.linux/Res/TileMaps/tiles-hd.png deleted: tests/test.linux/Res/TileMaps/tiles.png deleted: tests/test.linux/Res/TileMaps/tmw_desert_spacing-hd.png deleted: tests/test.linux/Res/TileMaps/tmw_desert_spacing.png deleted: tests/test.linux/Res/animations/dragon_animation-hd.png deleted: tests/test.linux/Res/animations/dragon_animation.png deleted: tests/test.linux/Res/animations/ghosts.plist deleted: tests/test.linux/Res/animations/ghosts.png deleted: tests/test.linux/Res/animations/grossini-aliases.plist deleted: tests/test.linux/Res/animations/grossini-aliases.png deleted: tests/test.linux/Res/animations/grossini.plist deleted: tests/test.linux/Res/animations/grossini.plist.xml deleted: tests/test.linux/Res/animations/grossini.png deleted: tests/test.linux/Res/animations/grossini.ztp deleted: tests/test.linux/Res/animations/grossini_blue.plist deleted: tests/test.linux/Res/animations/grossini_blue.png deleted: tests/test.linux/Res/animations/grossini_family.plist deleted: tests/test.linux/Res/animations/grossini_family.png deleted: tests/test.linux/Res/animations/grossini_gray.plist deleted: tests/test.linux/Res/animations/grossini_gray.png deleted: tests/test.linux/Res/app.config.txt deleted: tests/test.linux/Res/background.mp3 deleted: tests/test.linux/Res/effect1.wav deleted: tests/test.linux/Res/effect2.ogg deleted: tests/test.linux/Res/fonts/A Damn Mess.ttf deleted: tests/test.linux/Res/fonts/Abberancy.ttf deleted: tests/test.linux/Res/fonts/Abduction.ttf deleted: tests/test.linux/Res/fonts/Paint Boy.ttf deleted: tests/test.linux/Res/fonts/Schwarzwald Regular.ttf deleted: tests/test.linux/Res/fonts/Scissor Cuts.ttf deleted: tests/test.linux/Res/fonts/arial16.fnt deleted: tests/test.linux/Res/fonts/arial16.png deleted: tests/test.linux/Res/fonts/bitmapFontTest.fnt deleted: tests/test.linux/Res/fonts/bitmapFontTest.png deleted: tests/test.linux/Res/fonts/bitmapFontTest2.fnt deleted: tests/test.linux/Res/fonts/bitmapFontTest2.png deleted: tests/test.linux/Res/fonts/bitmapFontTest3.fnt deleted: tests/test.linux/Res/fonts/bitmapFontTest3.png deleted: tests/test.linux/Res/fonts/bitmapFontTest4.fnt deleted: tests/test.linux/Res/fonts/bitmapFontTest4.png deleted: tests/test.linux/Res/fonts/bitmapFontTest5.fnt deleted: tests/test.linux/Res/fonts/bitmapFontTest5.png deleted: tests/test.linux/Res/fonts/fps_images-hd.png deleted: tests/test.linux/Res/fonts/fps_images.png deleted: tests/test.linux/Res/fonts/futura-48.fnt deleted: tests/test.linux/Res/fonts/futura-48.png deleted: tests/test.linux/Res/fonts/konqa32-hd.fnt deleted: tests/test.linux/Res/fonts/konqa32-hd.png deleted: tests/test.linux/Res/fonts/konqa32.fnt deleted: tests/test.linux/Res/fonts/konqa32.png deleted: tests/test.linux/Res/fonts/larabie-16-hd.png deleted: tests/test.linux/Res/fonts/larabie-16.png deleted: tests/test.linux/Res/fonts/tuffy_bold_italic-charmap-hd.png deleted: tests/test.linux/Res/fonts/tuffy_bold_italic-charmap.png deleted: tests/test.linux/Res/music.mid deleted: tests/test.linux/Res/zwoptex/grossini-generic.plist deleted: tests/test.linux/Res/zwoptex/grossini-generic.png deleted: tests/test.linux/Res/zwoptex/grossini.plist deleted: tests/test.linux/Res/zwoptex/grossini.png CocosDenshion/AndroidDebug/ CocosDenshion/AndroidRelease/ HelloCocos2dx/AndroidDebug/2 HelloCocos2dx/android/assets HelloCocos2dx/postCompiled.sh installLinuxLib.sh
2011-08-23 11:28:04 +08:00
/*===============================================================================================
DSP Effect per speaker Example
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
This example shows how to manipulate a DSP network and as an example, creates 2 dsp effects,
and splits a single sound into 2 audio paths, which it then filters seperately.
To only have each audio path come out of one speaker each, FMOD_DSPConnection_setLevels is used just
before the 2 branches merge back together again.
For more speakers:
1. Use FMOD_System_SetSpeakerMode or FMOD_System_SetOutputFormat.
2. Create more effects, currently 2 for stereo (reverb and chorus), create one per speaker.
3. Under the 'Now connect the 2 effects to channeldsp head.' section, connect the extra effects
by duplicating the code more times.
4. Filter each effect to each speaker by calling FMOD_DSP_SetInputLevels. Expand the existing code
by extending the level arrays from 2 to the number of speakers you require, and change the
numlevels parameter in FMOD_DSP_SetInputLevels from 2 to the correct number accordingly.
===============================================================================================*/
#include "../common/wincompat.h"
#include "../../api/inc/fmod.h"
#include "../../api/inc/fmod_errors.h"
void ERRCHECK(FMOD_RESULT result)
{
if (result != FMOD_OK)
{
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
exit(-1);
}
}
int main(int argc, char *argv[])
{
FMOD_SYSTEM *system;
FMOD_SOUND *sound;
FMOD_CHANNEL *channel;
FMOD_DSP *dsplowpass, *dspchorus, *dsphead, *dspchannelmixer;
FMOD_DSPCONNECTION *dsplowpassconnection, *dspchorusconnection;
FMOD_RESULT result;
int key;
unsigned int version;
float pan = 0;
/*
Create a System object and initialize.
*/
result = FMOD_System_Create(&system);
ERRCHECK(result);
result = FMOD_System_GetVersion(system, &version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
return 0;
}
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
result = FMOD_System_CreateSound(system, "../media/drumloop.wav", FMOD_SOFTWARE | FMOD_LOOP_NORMAL, 0, &sound);
ERRCHECK(result);
printf("===============================================================================\n");
printf("DSP Effect per speaker example. Copyright (c) Firelight Technologies 2004-2011.\n");
printf("===============================================================================\n");
printf("Press 'L' to toggle reverb on/off on left speaker only\n");
printf("Press 'R' to toggle chorus on/off on right speaker only\n");
printf("Press '[' to pan sound left\n");
printf("Press ']' to pan sound right\n");
printf("Press 'Esc' to quit\n");
printf("\n");
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, FALSE, &channel);
ERRCHECK(result);
/*
Create the DSP effects.
*/
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_REVERB, &dsplowpass);
ERRCHECK(result);
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_CHORUS, &dspchorus);
ERRCHECK(result);
/*
Connect up the DSP network
*/
/*
When a sound is played, a subnetwork is set up in the DSP network which looks like this.
Wavetable is the drumloop sound, and it feeds its data from right to left.
[DSPHEAD]<------------[DSPCHANNELMIXER]
*/
result = FMOD_System_GetDSPHead(system, &dsphead);
ERRCHECK(result);
result = FMOD_DSP_GetInput(dsphead, 0, &dspchannelmixer, 0);
ERRCHECK(result);
/*
Now disconnect channeldsp head from wavetable to look like this.
[DSPHEAD] [DSPCHANNELMIXER]
*/
result = FMOD_DSP_DisconnectFrom(dsphead, dspchannelmixer);
ERRCHECK(result);
/*
Now connect the 2 effects to channeldsp head.
Store the 2 connections this makes so we can set their speakerlevels later.
[DSPLOWPASS]
/x
[DSPHEAD] [DSPCHANNELMIXER]
\y
[DSPCHORUS]
*/
result = FMOD_DSP_AddInput(dsphead, dsplowpass, &dsplowpassconnection); /* x = dsplowpassconnection */
ERRCHECK(result);
result = FMOD_DSP_AddInput(dsphead, dspchorus, &dspchorusconnection); /* y = dspchorusconnection */
ERRCHECK(result);
/*
Now connect the wavetable to the 2 effects
[DSPLOWPASS]
/x \
[DSPHEAD] [DSPCHANNELMIXER]
\y /
[DSPCHORUS]
*/
result = FMOD_DSP_AddInput(dsplowpass, dspchannelmixer, NULL); /* Null for connection - we dont care about it. */
ERRCHECK(result);
result = FMOD_DSP_AddInput(dspchorus, dspchannelmixer, NULL); /* Null for connection - we dont care about it. */
ERRCHECK(result);
/*
Now the drumloop will be twice as loud, because it is being split into 2, then recombined at the end.
What we really want is to only feed the dspchannelmixer->dsplowpass through the left speaker, and
dspchannelmixer->dspchorus to the right speaker.
We can do that simply by setting the pan, or speaker levels of the connections.
[DSPLOWPASS]
/x=1,0 \
[DSPHEAD] [DSPCHANNELMIXER]
\y=0,1 /
[DSPCHORUS]
*/
{
float leftinputon[2] = { 1.0f, 0.0f };
float rightinputon[2] = { 0.0f, 1.0f };
float inputsoff[2] = { 0.0f, 0.0f };
result = FMOD_DSPConnection_SetLevels(dsplowpassconnection, FMOD_SPEAKER_FRONT_LEFT, leftinputon, 2);
ERRCHECK(result);
result = FMOD_DSPConnection_SetLevels(dsplowpassconnection, FMOD_SPEAKER_FRONT_RIGHT, inputsoff, 2);
ERRCHECK(result);
result = FMOD_DSPConnection_SetLevels(dspchorusconnection, FMOD_SPEAKER_FRONT_LEFT, inputsoff, 2);
ERRCHECK(result);
result = FMOD_DSPConnection_SetLevels(dspchorusconnection, FMOD_SPEAKER_FRONT_RIGHT, rightinputon, 2);
ERRCHECK(result);
}
result = FMOD_DSP_SetBypass(dsplowpass, TRUE);
result = FMOD_DSP_SetBypass(dspchorus, TRUE);
result = FMOD_DSP_SetActive(dsplowpass, TRUE);
result = FMOD_DSP_SetActive(dspchorus, TRUE);
/*
Main loop.
*/
do
{
if (kbhit())
{
key = getch();
switch (key)
{
case 'l' :
case 'L' :
{
static int reverb = FALSE;
FMOD_DSP_SetBypass(dsplowpass, reverb);
reverb = !reverb;
break;
}
case 'r' :
case 'R' :
{
static int chorus = FALSE;
FMOD_DSP_SetBypass(dspchorus, chorus);
chorus = !chorus;
break;
}
case '[' :
{
FMOD_Channel_GetPan(channel, &pan);
pan -= 0.1f;
if (pan < -1)
{
pan = -1;
}
FMOD_Channel_SetPan(channel, pan);
break;
}
case ']' :
{
FMOD_Channel_GetPan(channel, &pan);
pan += 0.1f;
if (pan > 1)
{
pan = 1;
}
FMOD_Channel_SetPan(channel, pan);
break;
}
}
}
FMOD_System_Update(system);
{
int channelsplaying = 0;
FMOD_System_GetChannelsPlaying(system, &channelsplaying);
printf("Channels Playing %2d : Pan = %.02f\r", channelsplaying, pan);
}
fflush(stdout);
Sleep(10);
} while (key != 27);
printf("\n");
/*
Shut down
*/
result = FMOD_Sound_Release(sound);
ERRCHECK(result);
result = FMOD_DSP_Release(dsplowpass);
ERRCHECK(result);
result = FMOD_DSP_Release(dspchorus);
ERRCHECK(result);
result = FMOD_System_Close(system);
ERRCHECK(result);
result = FMOD_System_Release(system);
ERRCHECK(result);
return 0;
}