From 679ef20c53a7f05a1daacbfbf598198c15e5f367 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 19 Feb 2025 17:00:56 +0100 Subject: [PATCH] Removed the midi api. --- sfw/audio/audio.cpp | 53 --------------------------------------------- sfw/audio/audio.h | 21 ++++++++++++++---- 2 files changed, 17 insertions(+), 57 deletions(-) diff --git a/sfw/audio/audio.cpp b/sfw/audio/audio.cpp index 694ddac..94e6778 100644 --- a/sfw/audio/audio.cpp +++ b/sfw/audio/audio.cpp @@ -1,59 +1,6 @@ // @fixme: really shutdown audio & related threads before quitting. ma_dr_wav crashes. -#if is(win32) && !is(gcc) -#include -#include // midi -static HMIDIOUT midi_out_handle = 0; -#elif is(osx) -static AudioUnit midi_out_handle = 0; -#endif - -static void midi_init() { -#if is(win32) && !is(gcc) - if( midiOutGetNumDevs() != 0 ) { - midiOutOpen(&midi_out_handle, 0, 0, 0, 0); - } -#elif is(osx) - AUGraph graph; - AUNode outputNode, mixerNode, dlsNode; - NewAUGraph(&graph); - AudioComponentDescription output = {'auou','ahal','appl',0,0}; - AUGraphAddNode(graph, &output, &outputNode); - AUGraphOpen(graph); - AUGraphInitialize(graph); - AUGraphStart(graph); - AudioComponentDescription dls = {'aumu','dls ','appl',0,0}; - AUGraphAddNode(graph, &dls, &dlsNode); - AUGraphNodeInfo(graph, dlsNode, NULL, &midi_out_handle); - AudioComponentDescription mixer = {'aumx','smxr','appl',0,0}; - AUGraphAddNode(graph, &mixer, &mixerNode); - AUGraphConnectNodeInput(graph,mixerNode,0,outputNode,0); - AUGraphConnectNodeInput(graph,dlsNode,0,mixerNode,0); - AUGraphUpdate(graph,NULL); -#endif -} - -static void midi_quit() { -#if is(win32) && !is(gcc) - if (midi_out_handle) midiOutClose(midi_out_handle); -#endif - // @fixme: osx - // https://developer.apple.com/library/archive/samplecode/PlaySoftMIDI/Listings/main_cpp.html#//apple_ref/doc/uid/DTS40008635-main_cpp-DontLinkElementID_4 -} - -void midi_send(unsigned midi_msg) { -#if is(win32) && !is(gcc) - if( midi_out_handle ) { - midiOutShortMsg(midi_out_handle, midi_msg); - } -#elif is(osx) - if( midi_out_handle ) { - MusicDeviceMIDIEvent(midi_out_handle, (midi_msg) & 0xFF, (midi_msg >> 8) & 0xFF, (midi_msg >> 16) & 0xFF, 0); - } -#endif -} - // encapsulate ma_dr_wav,ma_dr_mp3,stbvorbis and some buffer with the sts_mixer_stream_t enum { UNK, WAV, OGG, MP1, MP3 }; typedef struct { diff --git a/sfw/audio/audio.h b/sfw/audio/audio.h index 5c5a373..67ff8ba 100644 --- a/sfw/audio/audio.h +++ b/sfw/audio/audio.h @@ -1,3 +1,13 @@ +//--STRIP +#ifndef AUDIO_H +#define AUDIO_H +//--STRIP + +//--STRIP +#include "object/object.h" +#include "object/reference.h" +//--STRIP + // ----------------------------------------------------------------------------- // audio framework // - rlyeh, public domain @@ -8,16 +18,14 @@ // @todo: destroystream() if( ss->type == MOD ) jar_mod_unload(&ss->mod); // @todo: destroystream() if( ss->type == XM && ss->xm ) jar_xm_free_context(ss->xm); -// midi interface - -void midi_send(unsigned midi_msg); - // audio interface typedef struct audio_handle* audio_t; audio_t audio_clip( const char *pathfile ); audio_t audio_stream( const char *pathfile ); + + int audio_play( audio_t s, int flags ); int audio_play_gain( audio_t a, int flags, float gain/*0*/ ); int audio_play_gain_pitch( audio_t a, int flags, float gain, float pitch/*1*/ ); @@ -56,3 +64,8 @@ enum AUDIO_FLAGS { }; int audio_queue( const void *samples, int num_samples, int flags ); + + +//--STRIP +#endif +//--STRIP