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      <div class="section">
14        <p>
15        Demonstrates how to play sounds in a file not included in a sound archive.
16        </p>
17      </div>
18
19      <h2>How to Use</h2>
20      <div class="section">
21        <p>
22        <ul>
23          <li>A Button: Plays the sound</li>
24          <li>X Button: Plays the sound</li>
25          <li>B Button: Stops the sound</li>
26        </ul>
27        </p>
28      </div>
29
30      <h2>Description</h2>
31      <div class="section">
32        <p>
33        Demonstrates a sample implementation that plays sounds using a file not included in a sound archive.
34        </p>
35        <p>
36        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.
37        </p>
38        <pre>
39    // Loads only wave sound data into the sound heap
40    if ( ! m_DataManager.LoadData( WSD_YOSHI, &amp;m_Heap, nw::snd::SoundDataManager::LOAD_WSD ) )
41      </pre>
42        <p>
43        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.
44        </P>
45        <pre>
46    // Loads a waveform archive file into memory
47    {
48        nn::fs::FileReader reader( EXTERNAL_FILE_PATH );
49        m_LengthForExternalFile = (s32)reader.GetSize();
50        m_pMemoryForExternalFile = MemAlloc( m_LengthForExternalFile, 32 );
51        (void)reader.Read( m_pMemoryForExternalFile, m_LengthForExternalFile );
52        reader.Finalize();
53    }
54
55    // Registers the loaded wave archive as WARC_TEXT (originally bound to WSD_YOSHI).
56    {
57        u32 fileId = m_Archive.GetItemFileId( WARC_TEST );
58        m_DataManager.SetFileAddress( fileId, m_pMemoryForExternalFile );
59    }
60
61    // Unregisters SoundDataManager and frees the wave archive file from memory
62    // {
63    //     m_DataManager.InvalidateSoundData(
64    //             m_pMemoryForExternalFile, m_LengthForExternalFile );
65    //     MemFree( m_pMemoryForExternalFile );
66    // }
67      </pre>
68        <p>
69        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.
70        </p>
71        <p>
72        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.
73        </p>
74        <p>
75        For example, sequence sound files only can be distributed and played as download content by using a bank originally included in a sound archive.
76        </p>
77      </div>
78
79      <h2>Revision History</h2>
80      <div class="section">
81        <dl class="history">
82          <dt>2010/09/27</dt>
83          <dd>Initial version.<br />
84          </dd>
85        </dl>
86      </div>
87
88    <hr><p>CONFIDENTIAL</p></body>
89  </html>
90
91