⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 record_8c-source.html

📁 MP3播放器源代码, VS1003B
💻 HTML
📖 第 1 页 / 共 2 页
字号:
00210       <span class="comment">//dataBufPtr should point inside disk buffer, this should never fail:</span>00211       <span class="keywordflow">if</span> (<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>&gt;(<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>+511)){00212         ConsoleWrite(<span class="stringliteral">"\rBuffer indexing error. Stop.\r"</span>);00213         <span class="keywordflow">while</span>(1); <span class="comment">//stop</span>00214       }00215       00216       <span class="comment">//Get the data</span>00217       <span class="keywordflow">for</span> (<a class="code" href="board_8c.html#a0">temp</a>.<a class="code" href="unionTemp.html#o0">c</a>=0;<a class="code" href="board_8c.html#a0">temp</a>.<a class="code" href="unionTemp.html#o0">c</a>&lt;128;<a class="code" href="board_8c.html#a0">temp</a>.<a class="code" href="unionTemp.html#o0">c</a>++){00218         data <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;00219         i = <a class="code" href="vs10xx_8h.html#a38">Mp3ReadRegister</a>(<a class="code" href="vs10xx_8h.html#a10">SPI_HDAT0</a>);         00220         *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++ = (i&gt;&gt;8);00221         *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++ = (i&amp;0xff);00222       }00223       00224       00225       { <span class="comment">//Do basic SOUND LEVEL BAR calculation based on the 1 linear</span>00226         <span class="comment">//sample in block[0] and [1]</span>00227         <span class="keywordtype">signed</span> <span class="keywordtype">int</span> soundlevel;00228         <span class="comment">// the user interface (level bar) calculation</span>00229         <span class="keywordflow">if</span> (<a class="code" href="player_8c.html#a6">uiMode</a> == <a class="code" href="ui_8h.html#a24a2">UI_TITLE</a>){00230           soundlevel = (<span class="keywordtype">signed</span> <span class="keywordtype">char</span>)<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[1]&lt;&lt;7;00231           soundlevel |= <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0]&gt;&gt;1;00232           <span class="keywordflow">if</span> (soundlevel&lt;0) soundlevel = -soundlevel;00233           <a class="code" href="display_8c.html#a5">displayValue</a>=0;00234           <span class="keywordflow">while</span> (soundlevel&gt;31){00235             <a class="code" href="display_8c.html#a5">displayValue</a>++;         00236             soundlevel&gt;&gt;=1;00237           }00238           <span class="keywordflow">if</span> (soundlevel&gt;19) <a class="code" href="display_8c.html#a5">displayValue</a>++;00239           <span class="keywordflow">if</span> (soundlevel&gt;12) <a class="code" href="display_8c.html#a5">displayValue</a>++;00240           <span class="keywordflow">if</span> (soundlevel&gt;6) <a class="code" href="display_8c.html#a5">displayValue</a>++;00241           <a class="code" href="display_8c.html#a5">displayValue</a>-=3;00242           <a class="code" href="display_8c.html#a5">displayValue</a>*=13;00243           <span class="keywordflow">if</span> (oldlevel&gt;<a class="code" href="display_8c.html#a5">displayValue</a>){00244             <a class="code" href="display_8c.html#a5">displayValue</a>=oldlevel-3;00245           }00246           oldlevel=<a class="code" href="display_8c.html#a5">displayValue</a>;       00247         }     00248         <a class="code" href="player_8c.html#a12">AvailableProcessorTime</a>();00249         00250       }<span class="comment">//SOUND LEVEL BAR calculation</span>00251       00252     }<span class="comment">//if there was data to read</span>00253     00254     00255     <span class="comment">//Release SCI chip select, we might want to use MMC card</span>00256     <a class="code" href="board_8h.html#a5">Mp3DeselectControl</a>();00257     00258     <span class="keywordflow">if</span> (blockNumber==2){ <span class="comment">//2 blocks (512 bytes) received, write to disk...</span>00259       00260       <span class="comment">//If we update the SPI_DECODE_TIME, it will show on player screen :)</span>00261       <span class="comment">//we can do it, no problem. Here is the calculation for 16khz;</span>00262       <span class="comment">//for 16kHz sample rate, 505 samples/block, 8 disk sectors are</span>00263       <span class="comment">//exactly 505 milliseconds. </span>00264       <a class="code" href="board_8c.html#a0">temp</a>.<a class="code" href="unionTemp.html#o2">l</a> = (sectorCount/8) * 505;00265       <a class="code" href="board_8c.html#a0">temp</a>.<a class="code" href="unionTemp.html#o2">l</a> /= 1000;00266       <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(<a class="code" href="vs10xx_8h.html#a6">SPI_DECODE_TIME</a>,<a class="code" href="board_8c.html#a0">temp</a>.<a class="code" href="unionTemp.html#o7">b</a>.b1,<a class="code" href="board_8c.html#a0">temp</a>.<a class="code" href="unionTemp.html#o7">b</a>.b0);00267       <a class="code" href="board_8h.html#a5">Mp3DeselectControl</a>();00268 00269       blockNumber = 0;00270       sectorCount++;00271       <a class="code" href="storage_8h.html#a4">WriteDiskSector</a>(<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a>);00272       lastSector = <a class="code" href="filesys_8c.html#a10">freeSector</a>;00273       <a class="code" href="filesys_8c.html#a17">ScanForFreeSector</a>(); <span class="comment">//this would be the proper way to go...</span>00274       <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> = <a class="code" href="filesys_8c.html#a10">freeSector</a>; <span class="comment">//keep all variables in proper values</span>00275       <a class="code" href="buffer_8c.html#a1">dataBufPtr</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>; <span class="comment">//reset data buffer pointer</span>00276       <span class="keywordflow">if</span> (<a class="code" href="filesys_8c.html#a10">freeSector</a>!=(lastSector+1)){ <span class="comment">//end of continuous space, must break!</span>00277         stopRecording = 1;00278         ConsoleWrite(<span class="stringliteral">"\nFragment end - can't continue recording!\n"</span>);00279         <a class="code" href="display_8h.html#a14">InitDisplay</a>(<a class="code" href="display_8h.html#a0">DS_STATIC</a>,<span class="stringliteral">"FRAGMENT"</span>,<span class="stringliteral">" LIMIT!!"</span>,0);00280         continueRecording = 1;00281       }00282     }00283     00284     <a class="code" href="display_8c.html#a5">displayValue</a> = 0;00285     00286   }<span class="comment">//while not button - stop recording when BUTTON is pressed</span>00287   <a class="code" href="filesys_8c.html#a6">fragment</a>[0].<a class="code" href="structfragmentEntry.html#o1">length</a> = sectorCount;00288   00289 00290   <span class="comment">//Enter size information to RIFF header..</span>00291   {00292     xdata <a class="code" href="unionAddress.html">addressType</a> size;00293 00294     <a class="code" href="storage_8h.html#a2">ReadDiskSector</a>(<a class="code" href="filesys_8c.html#a6">fragment</a>[0].start);00295     00296     <span class="comment">//Patch in number of samples</span>00297     size.l = (sectorCount-1)*1010;00298     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[48] = size.b.b0;00299     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[49] = size.b.b1;00300     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[50] = size.b.b2;00301     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[51] = size.b.b3;00302 00303     <span class="comment">//Patch in size of RIFF chunk...</span>00304     size.l = (sectorCount*512)-8;00305     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[4] = size.b.b0;00306     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[5] = size.b.b1;00307     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[6] = size.b.b2;00308     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[7] = size.b.b3;00309 00310     <span class="comment">//Patch in size of DATA chunk...</span>00311     size.l = (sectorCount*512)-512;00312     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[508] = size.b.b0;00313     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[509] = size.b.b1;00314     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[510] = size.b.b2;00315     <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[511] = size.b.b3;00316 00317     <a class="code" href="storage_8h.html#a4">WriteDiskSector</a>(<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a>);00318   }00319 00320   ConsoleWrite(<span class="stringliteral">"Registering... FStart:"</span>);00321   ConsolePutUInt(<a class="code" href="filesys_8c.html#a6">fragment</a>[0].start);00322   ConsoleWrite(<span class="stringliteral">"Registering... Size:"</span>);00323   ConsolePutUInt(<a class="code" href="filesys_8c.html#a6">fragment</a>[0].length);00324   00325   <span class="comment">//Create FAT records.</span>00326   <a class="code" href="filesys_8c.html#a6">fragment</a>[1].<a class="code" href="structfragmentEntry.html#o0">start</a> = 0x0fffffff; <span class="comment">//fragment 0 is the only fragment</span>00327   <a class="code" href="filesys_8c.html#a16">WriteClusterChain</a>(); <span class="comment">//register newly created file in FAT FS</span>00328 00331   <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> = 0; <span class="comment">//force sector reload for next access</span>00332   00333   <a class="code" href="vs10xx_8c.html#a3">Mp3Reset</a>();00334   <span class="keywordflow">if</span> (continueRecording) <span class="keywordflow">return</span> <a class="code" href="ui_8h.html#a25a23">PS_RECORDING</a>;00335   <span class="keywordflow">return</span> <a class="code" href="ui_8h.html#a25a14">PS_NEXT_SONG</a>;00336   00337 }00338 </div></pre><hr><FONT SIZE="-1">All software copyright 2000-2004 <a href="http://www.vlsi.fi/"> VLSI Solution OY.</a>Redistribution of these software modules are limited to promotional use onlyand only with the VS1011 / VS1002 / VS1003  MP3-Evakit evaluation boards. Free orcommercial use of these software modules in MP3 players is ok if theproduct includes MP3 decoder chip(s) from VLSI. You can request the complete(compilable) package from mp3@vlsi.fi</FONT>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -