|
/******************************************************************************
SDI 1.0
A library for Auditory Display
Copyright 2004 Dong Lin
This file is part of SDI.
SDI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
SDI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with SDI; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Last Updated : Apr.15th, 2004
For any question, suggestion or failure report, please contact me by:
e-mail: jonathan1983@126.com
*******************************************************************************/
/******************************************************************
File Name: Earcon.h
Description:
Earcon Object
Note:
********************************************************************/
#if !defined(EARCON_H_51CA635A_695B_47CB_A0B5_DBFCFEB699F8_INCLUDED)
#define EARCON_H_51CA635A_695B_47CB_A0B5_DBFCFEB699F8_INCLUDED
//////////////////////////////////////////////////////////////
// Included Headers
////////////////////////
#include "SDIKernel.h"
//////////////////////////////////////////////////////////////
// Constants
////////////////////////
// Parameters for earcon object
#define SDI_EARCON_AUDIOCHANNELS (1)
#define SDI_EARCON_SAMPLERATE (22050)
#define SDI_EARCON_BITDEPTH (16)
/************** Obsolete*****************************
See readme.txt for tech notes.
****************************************************/
#define SDI_EARCON_NUM_DSBSECTION (15)
#define SDI_EARCON_SECTIONSIZE (3000)
#define SDI_EARCON_DSBUFFERSIZE (SDI_EARCON_NUM_DSBSECTION*SDI_EARCON_SECTIONSIZE)
#define SDI_EARCON_NUM_SRCSECTION (4)
#define SDI_EARCON_SOURCEBUFFERSIZE (SDI_EARCON_NUM_SRCSECTION*SDI_EARCON_SECTIONSIZE) // 4500*4
#define SDI_EARCON_DMBUFFERSIZE (100*1024)
/***************************************************/
#define SDI_EARCON_MAXEARCON (64) // Maxium number of earcon objects
#define MICROSEC_TO_100NANOSEC (10)
#define REFTIME_PER_SEC (10000000)
#define SDI_EARCON_NUM_CHANNEL (16)
#define HIGHNOTE (119)
#define LOWNOTE (24)
// Message
#define MSG_EARCON_QUIT 0x0001
#define MSG_EARCON_PLAY 0x0002
#define MSG_EARCON_STOP 0x0003
#define MSG_EARCON_PAUSE 0x0004
// Refer to MIDI Specification for the following codes
// MIDI Message Code
#define NOTE_OFF 0x80
#define NOTE_ON 0x90
#define AFTER_TOUCH 0xA0
#define CONTROL_CHANGE 0xB0
#define PROGRAM_CHANGE 0xC0
#define CHANNEL_PRESSURE 0xD0
#define PITCH_WHEEL 0xE0
#define SYSTEM_EXCLUSIVE 0xF0
#define MTC_QUARTER_FRAME 0xF1
#define SONG_POSITION 0xF2
#define SONG_SELECT 0xF3
#define TUNE_REQUEST 0xF6
#define MIDI_CLOCK 0xF8
#define MIDI_START 0xFA
#define MIDI_CONTINUE 0xFB
#define MIDI_STOP 0xFC
#define ACTIVE_SENSE 0xFE
// MIDI File Format
// Meta-Event Type
#define NONMIDI 0xFF // Replace the RESET MIDI message
#define END_OF_TRACK 0x2F
// Controller Number
#define BANK_SELECT 0x00
// Status Mask
#define STATUS_EARCON_PLAYING 0x0001
//////////////////////////////////////////////////////////////
// Macros (Inline Functions)
////////////////////////
//////////////////////////////////////////////////////////////
// Structures
////////////////////////
struct SDIEARCONLIST{
COMMONDATA data;
DWORD timeSignature;
WORD keySignature;
FLOAT BPM;
DWORD dwTempo; // Microseconds Per Beat
WORD nTicksPerQN; // Delta-ticks Per Beat
WORD nChannelGroup;
IDirectMusicCollection8* pCollection; // Custom Instruments Collection
IDirectMusicDownloadedInstrument8* pDownloadedInstruments[SDI_EARCON_NUM_CHANNEL];
// Track
struct TRACK{
BYTE* pbData;
DWORD dwLength;
BYTE* pbCursor;
DWORD dwInterval;
BYTE byPrevStatus;
} track[SDI_EARCON_NUM_CHANNEL];
BYTE nTracks;
BYTE nCurTrack;
// Sound Display
IDirectSoundBuffer8* pSoundBuffer;
IDirectSound3DBuffer8* p3DBuffer;
IDirectMusicBuffer8* pMusicBuffer;
IDirectMusicPort8* pPort;
IReferenceClock* pClock;
HANDLE hDSBSync;
BYTE nDsbSec;
BYTE nSrcSec;
};
//////////////////////////////////////////////////////////////
// Function Prototypes
// [Non-exported]
////////////////////////
// Make 32-bit MIDI message
DWORD MakeVoiceMsg(BYTE byStatus, BYTE byChannel, BYTE byData1, BYTE byData2);
// Read MIDI message from file data pointer
DWORD ReadMsg(BYTE** ppData);
// Read and write variable-length number.
// Refer to "Standard MIDI-file Format Spec" for info on Variable length number.
DWORD ReadVarLen(BYTE** ppData);
BOOL WriteVarLen(BYTE** ppData, LONGLONG data_64);
// Read and write fixed-length number.
// cb: the number of bytes
DWORD ReadFixLen(BYTE** ppData, BYTE cb);
BOOL WriteFixLen(BYTE** ppData, DWORD data_64, BYTE cb);
BOOL ResetEarcon(SDIEARCONLIST* pEarcon);
BOOL RewindEarcon(SDIEARCONLIST* pEarcon);
BOOL PlayNonstop(HEARCON hEarcon, BYTE* pMusicData);
#endif //!defined(EARCON_H_51CA635A_695B_47CB_A0B5_DBFCFEB699F8_INCLUDED)
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
A student at Zhejiang University, Zhejiang, China.
Major in Automation.
Now I want to study machine vision and robotics, but I'm really consumed with choices between hardware and software, and between research and engineering.
I'll be glad if you can give some suggestions.