1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xml:lang="en-US" lang="en-US">
3  <head>
4    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5    <meta http-equiv="Content-Style-Type" content="text/css" />
6    <link rel="stylesheet" href="../../../css/manpage.css" type="text/css" />
7    <title>Sound (snd) Sample Demo</title>
8  </head>
9  <body>
10    <h1>externalFile</h1>
11
12      <h2>Overview</h2>
13      <p>
14        Demonstrates how to play sounds in a file not included in a sound archive.
15      </p>
16
17      <h2>How to Use</h2>
18      <p>
19        <ul>
20          <li>A Button: Plays the sound</li>
21          <li>X Button: Plays the sound</li>
22          <li>B Button: Stops the sound</li>
23        </ul>
24      </p>
25
26      <h2>Description</h2>
27      <p>
28        Demonstrates a sample implementation that plays sounds using a file not included in a sound archive.
29      </p>
30      <p>
31      In this demo, when loading wave sound data, only wave sound data is loaded because <a href="../SoundDataManager/Overview.html">nw::snd::SoundDataManager::</a>LOAD_WSD has been specified as the third argument to the <a href="../SoundDataManager/LoadData.html">nw::snd::SoundDataManager::LoadData</a> function. The wave archive that should be bound to WSD_YOSHI under SoundMaker is not loaded.
32      </p>
33      <pre>
34    // Loads only wave sound data into the sound heap
35    if ( ! m_DataManager.LoadData( WSD_YOSHI, &amp;m_Heap, nw::snd::SoundDataManager::LOAD_WSD ) )
36      </pre>
37      <p>
38      However, it is possible to load another wave archive file that does not include a sound archive, and then bind it as a WARC_TEXT waveform archive bound to the original WSD_YOSHI. By doing so, you can play sounds using a waveform achive other than the one originally bound.
39      </P>
40      <pre>
41    // Loads a waveform archive file into memory
42    {
43        nn::fs::FileReader reader( EXTERNAL_FILE_PATH );
44        m_LengthForExternalFile = (s32)reader.GetSize();
45        m_pMemoryForExternalFile = MemAlloc( m_LengthForExternalFile, 32 );
46        (void)reader.Read( m_pMemoryForExternalFile, m_LengthForExternalFile );
47        reader.Finalize();
48    }
49
50    // Registers the loaded wave archive as WARC_TEXT (originally bound to WSD_YOSHI).
51    {
52        u32 fileId = m_Archive.GetItemFileId( WARC_TEST );
53        m_DataManager.SetFileAddress( fileId, m_pMemoryForExternalFile );
54    }
55
56    // Unregisters SoundDataManager and frees the wave archive file from memory
57    // {
58    //     m_DataManager.InvalidateSoundData(
59    //             m_pMemoryForExternalFile, m_LengthForExternalFile );
60    //     MemFree( m_pMemoryForExternalFile );
61    // }
62      </pre>
63      <p>
64      EXTERNAL_FILE_PATH (= WARC_TEST.bcwar) which is loaded separately by this demo as a file not included in a sound archive is located in the cache folder created when converting from SoundMaker.
65      </p>
66      <p>
67      In this demo, it wouldn't mean much to take data originally bound under SoundMaker and bind it again in a program. However, this feature can be used to play sounds using data not contained in ROM from the beginning.
68      </p>
69      <p>
70      For example, sequence sound files only can be distributed and played as download content by using a bank originally included in a sound archive.
71      </p>
72
73    <h2>Revision History</h2>
74    <div class="section">
75      <dl class="history">
76        <dt>2010/09/27</dt>
77        <dd>Initial version.<br />
78        </dd>
79      </dl>
80    </div>
81
82  <hr><p>CONFIDENTIAL</p></body>
83</html>
84
85