labelString

Overview

Demonstrates how to use label strings instead of sound IDs.

How to Use

Description

Allows sounds to be played using label strings (const char*) rather than sound IDs.

A string table must already be loaded from a sound archive to do this.

    // Loads the STRING block
    {
        u32 stringBlockSize = m_Archive.GetLabelStringDataSize();
        m_pMemoryForStringBlock = MemAlloc( stringBlockSize );
        if ( ! m_Archive.LoadLabelStringData( m_pMemoryForStringBlock, stringBlockSize ) )
        {
            NW_ASSERTMSG( 0, "cannot load stringBlock(%s)", SOUND_ARC_PATH );
        }
    }
      

Label strings can also be used for loading data, not just for playing sounds.

    // Loads sound data
    if ( ! m_DataManager.LoadData( "SEQ_MARIOKART", &m_Heap ) )
    {
        NW_ASSERTMSG( false, "LoadData(SEQ_MARIOKART) failed." );
    }
    if ( ! m_DataManager.LoadData( "SE_YOSHI", &m_Heap ) )
    {
        NW_ASSERTMSG( false, "LoadData(SE_YOSHI) failed." );
    }

    // Plays the sound
    bool result = m_ArchivePlayer.StartSound( &m_Handle, "SEQ_MARIOKART" ).IsSuccess();
      

Loading is not required when using nw::snd::MemorySoundArchive. Furthermore, playback using label strings is impossible if the sound archive does not include a string table.

Whether a sound archive file includes string information can be specified by selecting Project Settings from the SoundMaker Projects menu, and then on the Sound Archive tab, selecting the "Ouput the string table" checkbox.

Revision History

2010/09/27
Initial version.

CONFIDENTIAL