Previous 199869 Revisions Next

r31372 Tuesday 22nd July, 2014 at 04:51:52 UTC by Justin Kerk
[JSMESS] Add shim for Web Audio sound module [Katelyn Gadd, Justin Kerk]
[src/osd/modules/sound]js_sound.c* js_sound.h*
[src/osd/sdl]sdl.mak sdlmain.c

trunk/src/osd/sdl/sdl.mak
r31371r31372
417417# add an ARCH define
418418DEFS += -DSDLMAME_ARCH="$(ARCHOPTS)" -DSYNC_IMPLEMENTATION=$(SYNC_IMPLEMENTATION)
419419
420# Add JavaScript sound module for Emscripten compiles
421
422ifeq ($(TARGETOS),emscripten)
423OSDOBJS += $(OSDOBJ)/modules/sound/js_sound.o
424endif
425
420426#-------------------------------------------------
421427# Generic defines and additions
422428#-------------------------------------------------
trunk/src/osd/sdl/sdlmain.c
r31371r31372
5050#include "osdsdl.h"
5151#include "sdlos.h"
5252#include "modules/sound/sdl_sound.h"
53#if defined(SDLMAME_EMSCRIPTEN)
54#include "modules/sound/js_sound.h"
55#endif
5356#if !defined(NO_DEBUGGER)
5457#include "modules/debugger/debugqt.h"
5558#endif
r31371r31372
540543void sdl_osd_interface::sound_register()
541544{
542545   sound_options_add("sdl", OSD_SOUND_SDL);
546#if defined(SDLMAME_EMSCRIPTEN)
547   sound_options_add("js", OSD_SOUND_JS);
548   sound_options_add("auto", OSD_SOUND_JS); // making JS audio default one
549#else
543550   sound_options_add("auto", OSD_SOUND_SDL); // making SDL audio default one
551#endif
544552}
545553
546554//============================================================
trunk/src/osd/modules/sound/js_sound.c
r0r31372
1// license:BSD-3-Clause
2// copyright-holders:Miodrag Milanovic, Katelyn Gadd
3/***************************************************************************
4
5    js_sound.c
6
7    Shim for native JavaScript sound interface implementations (Emscripten only).
8
9*******************************************************************c********/
10
11
12#include "js_sound.h"
13#include "emscripten.h"
14
15//-------------------------------------------------
16//  sound_js - constructor
17//-------------------------------------------------
18sound_js::sound_js(const osd_interface &osd)
19   : osd_sound_interface(osd)
20{
21}
22
23void sound_js::update_audio_stream(const INT16 *buffer, int samples_this_frame)
24{
25  EM_ASM_ARGS({
26    // Forward audio stream update on to JS backend implementation.
27    jsmess_update_audio_stream($0, $1);
28  }, (unsigned int)buffer, samples_this_frame);
29}
30
31void sound_js::set_mastervolume(int attenuation)
32{
33  EM_ASM_ARGS({
34    // Forward volume update on to JS backend implementation.
35    jsmess_set_mastervolume($0);
36  }, attenuation);
37}
38
39const osd_sound_type OSD_SOUND_JS = &osd_sound_creator<sound_js>;
Property changes on: trunk/src/osd/modules/sound/js_sound.c
Added: svn:eol-style
   + native
Added: svn:mime-type
   + text/plain
trunk/src/osd/modules/sound/js_sound.h
r0r31372
1// license:BSD-3-Clause
2// copyright-holders:Miodrag Milanovic, Katelyn Gadd
3/***************************************************************************
4
5    js_sound.h
6
7    Shim for native JavaScript sound interface implementations (Emscripten only).
8
9*******************************************************************c********/
10
11#pragma once
12
13#ifndef __SOUND_JS_H__
14#define __SOUND_JS_H__
15
16#include "osdepend.h"
17
18class sound_js : public osd_sound_interface
19{
20public:
21   // construction/destruction
22   sound_js(const osd_interface &osd);
23   virtual ~sound_js() { }
24   
25   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame);
26   virtual void set_mastervolume(int attenuation);
27};
28
29extern const osd_sound_type OSD_SOUND_JS;
30
31#endif  /* __SOUND_JS_H__ */
Property changes on: trunk/src/osd/modules/sound/js_sound.h
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Previous 199869 Revisions Next


© 1997-2024 The MAME Team