1
0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-02 00:42:53 +01:00
SpaceCadetPinball/SpaceCadetPinball
Patrice Levesque a4c6165094
Implement stereo sound. (#138)
* Implement stereo sound.

Original Space Cadet has mono sound.  To achieve stereo, the following
steps were accomplished:

- Add a game option to turn on/off stereo sound.  Default is on.

- TPinballComponent objects were extended with a method called
  get_coordinates() that returns a single 2D point, approximating the
  on-screen position of the object, re-mapped between 0 and 1 vertically
  and horizontally, {0, 0} being at the top-left.

    - For static objects like bumpers and lights, the coordinate refers
      to the geometric center of the corresponding graphic sprite, and
      is precalculated at initialization.

    - For ball objects, the coordinate refers to the geometric center of
      the ball, calculated during play when requested.

- Extend all calls to sound-playing methods so that they include a
  TPinballComponent* argument that refers to the sound source, e.g.
  where the sound comes from.  For instance, when a flipper is
  activated, its method call to emit a sound now includes a reference to
  the flipper object; when a ball goes under a SkillShotGate, its method
  call to emit a sound now includes a reference to the corresponding
  light; and so on.

  For some cases, like light rollovers, the sound source is taken from
  the ball that triggered the light rollover.

  For other cases, like holes, flags and targets, the sound source is
  taken from the object itself.

  For some special cases like ramp activation, sound source is
  taken from the nearest light position that makes sense.

  For all game-progress sounds, like mission completion sounds or ball
  drain sounds, the sound source is undefined (set to nullptr), and the
  Sound::PlaySound() method takes care of positioning them at a default
  location, where speakers on a pinball machine normally are.

- Make the Sound::PlaySound() method accept a new argument, a
  TPinballComponent reference, as described above.

  If the stereo option is turned on, the Sound::PlaySound() method calls
  the get_coordinates() method of the TPinballComponent reference to get
  the sound position.

  This project uses SDL_mixer and there is a function called
  Mix_SetPosition() that allows placing a sound in the stereo field, by
  giving it a distance and an angle.

  We arbitrarily place the player's ears at the bottom of the table; we
  set the ears' height to half a table's length.  Intensity of the
  stereo effect is directly related to this value; the farther the
  player's ears from the table, the narrowest the stereo picture gets,
  and vice-versa.

  From there we have all we need to calculate distance and angle; we do
  just that and position all the sounds.

* Copy-paste typo fix.
2022-05-30 10:35:29 +03:00
..
control.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
control.h control: reduced component indirection. 2022-02-10 16:29:31 +03:00
DebugOverlay.cpp Optimized SDL_RenderDrawCircle. 2022-05-27 13:54:36 +03:00
DebugOverlay.h Added debug overlay v1. 2022-05-19 14:17:31 +03:00
EmbeddedData.cpp Compressed and encoded embedded 3DPB font. 2021-09-29 10:08:45 +03:00
EmbeddedData.h Compressed and encoded embedded 3DPB font. 2021-09-29 10:08:45 +03:00
fullscrn.cpp Added FT demo data support. 2021-11-24 17:25:23 +03:00
fullscrn.h Added table resolution and UI scale options. 2021-09-22 15:50:07 +03:00
gdrv.cpp Added debug overlay v1. 2022-05-19 14:17:31 +03:00
gdrv.h Added debug overlay v1. 2022-05-19 14:17:31 +03:00
GroupData.cpp Added debug overlay v1. 2022-05-19 14:17:31 +03:00
GroupData.h Score: inject 3DPB msg font into dat struct. 2021-10-10 12:22:21 +03:00
high_score.cpp Fixed high score insertion for multiple players. 2022-04-11 10:28:20 +03:00
high_score.h Fixed high score insertion for multiple players. 2022-04-11 10:28:20 +03:00
Icon_1.ico Added icon, textbox font. 2020-12-11 19:03:13 +03:00
Icon_16x16.png Add linux desktop file and install (#100) 2021-12-02 08:07:27 +03:00
Icon_32x32.png Add linux desktop file and install (#100) 2021-12-02 08:07:27 +03:00
Icon_48x48.png Add linux desktop file and install (#100) 2021-12-02 08:07:27 +03:00
Icon_128x128.png Add assets (#113) 2021-12-26 13:06:31 +03:00
Icon_192x192.png Improve linux building (#111) 2021-12-24 09:09:40 +03:00
imconfig.h Added GUI, some menus dont work yet. 2021-09-05 10:47:05 +03:00
imgui_demo.cpp Added GUI, some menus dont work yet. 2021-09-05 10:47:05 +03:00
imgui_draw.cpp Compressed and encoded embedded 3DPB font. 2021-09-29 10:08:45 +03:00
imgui_impl_sdl.cpp fix X11 include leak (#136) 2022-05-06 07:58:53 +03:00
imgui_impl_sdl.h Added GUI, some menus dont work yet. 2021-09-05 10:47:05 +03:00
imgui_internal.h Added GUI, some menus dont work yet. 2021-09-05 10:47:05 +03:00
imgui_sdl.cpp winmain: reworked main loop for smoother frame times. 2021-09-28 08:14:18 +03:00
imgui_sdl.h Added GUI, some menus dont work yet. 2021-09-05 10:47:05 +03:00
imgui_tables.cpp Added GUI, some menus dont work yet. 2021-09-05 10:47:05 +03:00
imgui_widgets.cpp Added GUI, some menus dont work yet. 2021-09-05 10:47:05 +03:00
imgui.cpp Added GUI, some menus dont work yet. 2021-09-05 10:47:05 +03:00
imgui.h Compressed and encoded embedded 3DPB font. 2021-09-29 10:08:45 +03:00
imstb_rectpack.h Added GUI, some menus dont work yet. 2021-09-05 10:47:05 +03:00
imstb_textedit.h Added GUI, some menus dont work yet. 2021-09-05 10:47:05 +03:00
imstb_truetype.h Added GUI, some menus dont work yet. 2021-09-05 10:47:05 +03:00
loader.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
loader.h Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
maths.cpp Renamed some collision variables. 2022-05-20 11:51:00 +03:00
maths.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
midi.cpp Optimized SDL_RenderDrawCircle. 2022-05-27 13:54:36 +03:00
midi.h Refactored midi multiple track support. 2022-05-23 12:45:18 +03:00
NatvisFile.natvis Cleaning up maths: part 3. 2022-05-13 11:15:30 +03:00
nudge.cpp Renamed some collision variables. 2022-05-20 11:51:00 +03:00
nudge.h TBall, nudge v1, ready. 2020-12-27 18:19:36 +03:00
options.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
options.h Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
partman.cpp Added FT demo data support. 2021-11-24 17:25:23 +03:00
partman.h Replaced objlist_class with std::vector. 2021-10-01 18:55:44 +03:00
PB_MSGFT.bin Added icon, textbox font. 2020-12-11 19:03:13 +03:00
pb.cpp Added support for multiple music tracks in FT mode. 2022-05-20 19:32:09 +03:00
pb.h Fixed high score insertion for multiple players. 2022-04-11 10:28:20 +03:00
pch.h Added sound and music volume control. 2022-01-12 17:17:38 +03:00
pinball.cpp Added “Prefer 3DPB game data” option. 2021-11-21 15:40:56 +03:00
pinball.h Added “Prefer 3DPB game data” option. 2021-11-21 15:40:56 +03:00
proj.cpp Added debug overlay v1. 2022-05-19 14:17:31 +03:00
proj.h Added debug overlay v1. 2022-05-19 14:17:31 +03:00
render.cpp Added debug overlay v1. 2022-05-19 14:17:31 +03:00
render.h Improved frame time diagnostic tool. 2021-11-11 14:30:56 +03:00
score.cpp Score: inject 3DPB msg font into dat struct. 2021-10-10 12:22:21 +03:00
score.h Score: inject 3DPB msg font into dat struct. 2021-10-10 12:22:21 +03:00
Sound.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
Sound.h Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
SpaceCadetPinball.cpp Added UTF-8 path support on Windows. 2021-11-06 19:22:56 +03:00
SpaceCadetPinball.rc Mingw cross compilation (#24) 2021-10-07 12:53:56 +03:00
splash_bitmap.bmp splash ready. 2021-01-29 14:24:49 +03:00
TBall.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TBall.h Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TBlocker.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TBlocker.h control v2. 2021-01-20 17:28:48 +03:00
TBumper.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TBumper.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TCircle.cpp Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TCircle.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TCollisionComponent.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TCollisionComponent.h Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TComponentGroup.cpp Fix compiler warnings (#73) 2021-10-26 17:15:45 +03:00
TComponentGroup.h Replaced objlist_class with std::vector. 2021-10-01 18:55:44 +03:00
TDemo.cpp Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TDemo.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TDrain.cpp Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TDrain.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TEdgeBox.h Replaced objlist_class with std::vector. 2021-10-01 18:55:44 +03:00
TEdgeManager.cpp Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TEdgeManager.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TEdgeSegment.cpp Cleaning up maths: part 3. 2022-05-13 11:15:30 +03:00
TEdgeSegment.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TFlagSpinner.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TFlagSpinner.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TFlipper.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TFlipper.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TFlipperEdge.cpp Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TFlipperEdge.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TGate.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TGate.h TBlocker, TBumper, TFlagSpinner, TGate, THole, TKickback, TWall ready. 2021-01-16 17:45:29 +03:00
THole.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
THole.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
timer.cpp Replaced memory with new. 2021-10-02 17:45:31 +03:00
timer.h x64 build - no collision bug found( 2021-01-29 16:42:05 +03:00
TKickback.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TKickback.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TKickout.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TKickout.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TLight.cpp Replaced objlist_class with std::vector. 2021-10-01 18:55:44 +03:00
TLight.h TPinballComponent: replaced calloc operator new with member initialization. 2021-10-02 18:58:54 +03:00
TLightBargraph.cpp Fixed TLightGroup message 45 and 46, used by TLightBargraph. 2021-10-07 14:17:43 +03:00
TLightBargraph.h TPinballComponent: replaced calloc operator new with member initialization. 2021-10-02 18:58:54 +03:00
TLightGroup.cpp Increase precision of mode_countdown_ handling (#52) 2021-10-23 07:33:04 +03:00
TLightGroup.h TPinballComponent: replaced calloc operator new with member initialization. 2021-10-02 18:58:54 +03:00
TLightRollover.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TLightRollover.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TLine.cpp Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TLine.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TOneway.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TOneway.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TPinballComponent.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TPinballComponent.h Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TPinballTable.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TPinballTable.h TPinballComponent: replaced calloc operator new with member initialization. 2021-10-02 18:58:54 +03:00
TPlunger.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TPlunger.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TPopupTarget.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TPopupTarget.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TRamp.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TRamp.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TRollover.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TRollover.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TSink.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TSink.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TSoloTarget.cpp Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TSoloTarget.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TSound.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TSound.h Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TTableLayer.cpp Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TTableLayer.h Cleaning up maths: part 2. 2022-05-11 16:47:13 +03:00
TTextBox.cpp Added centered text in textboxes in FT mode. 2021-11-20 19:03:22 +03:00
TTextBox.h Added centered text in textboxes in FT mode. 2021-11-20 19:03:22 +03:00
TTextBoxMessage.cpp Demangled and simplified pbctrl_bdoor_controller. 2021-10-04 17:04:09 +03:00
TTextBoxMessage.h Demangled and simplified pbctrl_bdoor_controller. 2021-10-04 17:04:09 +03:00
TTimer.cpp TLight, TTimer, TSound, TComponentGroup ready. 2021-01-01 16:14:11 +03:00
TTimer.h TLight, TTimer, TSound, TComponentGroup ready. 2021-01-01 16:14:11 +03:00
TTripwire.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
TTripwire.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TWall.cpp Renamed some collision variables. 2022-05-20 11:51:00 +03:00
TWall.h Renamed some collision variables. 2022-05-20 11:51:00 +03:00
winmain.cpp Implement stereo sound. (#138) 2022-05-30 10:35:29 +03:00
winmain.h Simplified game mode, pause. 2022-01-05 11:38:50 +03:00
zdrv.cpp ColorRgba: replaced union with bit shifts. 2021-11-13 09:00:58 +03:00
zdrv.h Replaced memory with new. 2021-10-02 17:45:31 +03:00