CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

AUDIO.H (3768B)


      1 //
      2 // Copyright 2020 Electronic Arts Inc.
      3 //
      4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 
      5 // software: you can redistribute it and/or modify it under the terms of 
      6 // the GNU General Public License as published by the Free Software Foundation, 
      7 // either version 3 of the License, or (at your option) any later version.
      8 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /* $Header:   F:\projects\c&c\vcs\code\audio.h_v   2.18   16 Oct 1995 16:45:34   JOE_BOSTIC  $ */
     17 /***********************************************************************************************
     18  ***              C O N F I D E N T I A L  ---  W E S T W O O D  S T U D I O S               *** 
     19  ***********************************************************************************************
     20  *                                                                                             *
     21  *                 Project Name : Command & Conquer                                            *
     22  *                                                                                             *
     23  *                    File Name : AUDIO.H                                                      *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : June 21, 1994                                                *
     28  *                                                                                             *
     29  *                  Last Update : June 21, 1994   [JLB]                                        *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 #ifndef AUDIO_H
     36 #define AUDIO_H
     37 
     38 #include	"memory.h"
     39 
     40 class AudioClass {
     41 		char const * Name;	// Name of audio asset.
     42 		void const * Data;	// Loaded audio data.
     43 		int Handle;				// Handle of asset (as it is playing).
     44 		MemoryClass *Mem;		// Pointer to memory handler class.
     45 		unsigned IsMIDI:1;	// Is this a midi file?
     46 
     47 	public:
     48 		AudioClass(void);
     49 		AudioClass(char const *name, MemoryClass &mem);
     50 		virtual ~AudioClass(void);
     51 
     52 		bool Load(char const *name = 0);
     53 		bool Free(void);
     54 		bool Play(int volume = 0xFF);
     55 		bool Stop(void);
     56 		bool Pause(void);
     57 		bool Resume(void);
     58 		bool Set_Name(char const *name);
     59 		bool Is_Playing(void) const;
     60 		bool Is_Loaded(void) const;
     61 		bool Is_MIDI(void) const;
     62 };
     63 
     64 inline AudioClass::AudioClass(void)
     65 {
     66 	Name = 0; 
     67 	Data = 0; 
     68 	Mem = 0;
     69 	Handle = -1;
     70 };
     71 
     72 inline AudioClass::AudioClass(char const *name, MemoryClass &mem) 
     73 {
     74 	if (mem) {
     75 		Mem = &mem;
     76 	} else {
     77 		Mem = &::Mem;		// Uses global default memory handler.
     78 	}
     79 	Name = strdup(name);
     80 	Data = 0;
     81 	Handle = -1;
     82 };
     83 
     84 inline AudioClass::~AudioClass(void)
     85 {
     86 	if (GameActive) {
     87 		if (Name) free(Name);
     88 		if (Data) Mem->Free(Data);
     89 		Name = 0;
     90 		Data = 0;
     91 		Handle = -1;
     92 	}
     93 };
     94 
     95 
     96 #endif