1: /*
     2:  *  Guitar-ZyX(tm)::MasterControlProgram - portable guitar F/X controller
     3:  *  Copyright (C) 2009  Douglas McClendon
     4:  *
     5:  *  This program is free software: you can redistribute it and/or modify
     6:  *  it under the terms of the GNU General Public License as published by
     7:  *  the Free Software Foundation, version 3 of the License.
     8:  *
     9:  *  This program is distributed in the hope that it will be useful,
    10:  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    11:  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12:  *  GNU General Public License for more details.
    13:  *
    14:  *  You should have received a copy of the GNU General Public License
    15:  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16: */
    17: /*
    18: #############################################################################
    19: #############################################################################
    20: ## 
    21: ## gzmcpc::sound: sound functions
    22: ##
    23: #############################################################################
    24: ##
    25: ## Copyright 2008-2009 Douglas McClendon <dmc AT filteredperception DOT org>
    26: ##
    27: #############################################################################
    28: #############################################################################
    29: #
    30: */
    31: 
    32: 
    33: 
    34: 
    35: #include <nds.h> 
    36: #include <maxmod9.h> 
    37: 
    38: #include "sound.h" 
    39: 
    40: 
    41: #include "sounds.h" 
    42: #include "sounds_bin.h" 
    43: 
    44: 
    45: 
    46: 
    47: mm_sound_effect sounds[MSL_NSAMPS];
    48: 
    49: 
    50: 
    51: 
    52: void gzmcpc_init_sound(void) {
    53: 
    54:   int i;
    55: 
    56:   // initialize maxmod sound system
    57:   mmInitDefaultMem((mm_addr)sounds_bin);
    58: 
    59:   //
    60:   // load sound effects                                                                                  
    61:   //
    62: 
    63:   // note, i here is being used for enumerated values, i.e.
    64:   // things like SFX_STARTUP, SFX_ONLINE, ...
    65:   for (i = 0 ; i < MSL_NSAMPS ; i++) {
    66:     mmLoadEffect(i);
    67:     // this variable(s) is used to optionally tailor playback
    68:     sounds[i].id = i;
    69:     sounds[i].rate = 1024;
    70:     sounds[i].handle = 0;
    71:     sounds[i].volume = 255;
    72:     sounds[i].panning = 127;
    73:   }
    74: 
    75: }
    76: 
    77: 
    78: void mcp_snd_click(void) {
    79: 
    80:   int save_volume;
    81: 
    82:   save_volume = sounds[SFX_METROGNOME].volume;
    83:   sounds[SFX_METROGNOME].volume = save_volume / 4;
    84:   mmEffectEx(&sounds[SFX_METROGNOME]);
    85:   sounds[SFX_METROGNOME].volume = save_volume;
    86: }
    87: 
    88: 
    89: void end_sound(void) {
    90: 
    91:   int i;
    92: 
    93:   // free all sound resources
    94:   for (i = 0 ; i < MSL_NSAMPS ; i++) {
    95:     mmUnloadEffect(i);
    96:   }
    97: }
    98: