1 /** 2 * This file is part of the Web Enabled Audio and Sound Enhancement Library (aka the Weasel audio library) Copyright 2011 - 2013 Warren Willmey. It is covered by the GNU General Public License version 3 as published by the Free Software Foundation, you should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. 3 */ 4 5 if( undefined == window.weasel ) window.weasel = {}; 6 7 // --------------------------------------------------------------------------- 8 /** Create a Mnemotron's Spreadpoint Soundtracker 2.3 module out of the provided data (which has already passed the module sniffer test). 9 * Spreadpoint Soundtracker 2.3 is the origin of the M.K. format and extends the 10 * DOC Soundtracker 2.2 by adding 16 samples (total 31) and the Volume Slide Command. 11 * 12 * @constructor 13 * @extends weasel.DOCSoundTracker22 14 * 15 * @param {Array|Uint8Array} aModuleData = The Spreadpoint Soundtracker 2.3 module as a byte array that MUST have passed the module sniffer test. 16 * @param {int} iPlaybackFrequency = The playback frequency in hertz to use (e.g. 44100 ). 17 * @param {weasel.Sample.prototype.SampleScannerMode} iSampleScannerMode = Scan for IFF Header corruption residue?. 18 * 19 * @author Warren Willmey 2012 20 */ 21 weasel.SpreadpointSoundTracker23 = function( aModuleData, iPlaybackFrequency, iSampleScannerMode ) 22 { 23 this.parent = weasel.DOCSoundTracker22; 24 25 // Needed for prototype Inheritance. 26 // 27 if( aModuleData === undefined || !(( aModuleData instanceof Array ) || ( window.Uint8Array && aModuleData instanceof Uint8Array )) ) 28 return; 29 30 this.parent( aModuleData, iPlaybackFrequency, iSampleScannerMode ); 31 32 this.sModuleType = weasel.ModuleSniffer.prototype.SupportedModules.SpreadpointSoundTracker23; 33 34 }; 35 36 weasel.SpreadpointSoundTracker23.prototype = new weasel.DOCSoundTracker22; 37 38 // --------------------------------------------------------------------------- 39 /** Get the number of instruments supported by the module format. 40 * 41 * @return {int} The total number of instruments this format supports ( 31 for M.K. Spreadpoint Soundtracker etc). 42 */ 43 weasel.SpreadpointSoundTracker23.prototype.FormatInstrumentTotal = function( ) 44 { 45 return weasel.FormatSpreadpointSoundTracker23.NumberOfInstruments; 46 }; 47 48 // --------------------------------------------------------------------------- 49 /** Get the Module Header Size used by the module format, it is also the starting offset for the pattern data. 50 * 51 * @return {int} the Module Header Size used by the module format, it is also the starting offset for the pattern data. 52 */ 53 weasel.SpreadpointSoundTracker23.prototype.FormatModuleHeaderSize = function( ) 54 { 55 return weasel.FormatSpreadpointSoundTracker23.ModuleHeaderSize; 56 }; 57 58 // --------------------------------------------------------------------------- 59 /** 60 * Extract song speed from M.K. 31 instrument module (its at a different offset). 61 * 62 * @protected 63 * @override 64 */ 65 weasel.SpreadpointSoundTracker23.prototype._extractSongSpeed = function( ) 66 { 67 try 68 { 69 var iSongSpeed = weasel.Helper.getByte( this.aModuleData, weasel.FormatSpreadpointSoundTracker23.SongSpeed ); 70 this.setSongSpeed( iSongSpeed ); 71 }catch ( oException ) 72 { 73 } 74 }; 75 76 // --------------------------------------------------------------------------- 77 /** 78 * Get the pattern sequence table in M.K. 31 instrument module as its in a different location. 79 * 80 * @return {Array} = The Pattern Sequence Table. 81 */ 82 weasel.SpreadpointSoundTracker23.prototype.getSequenceTable = function() 83 { 84 if( null != this.aSequenceTable ) 85 return this.aSequenceTable; 86 87 var aPatternSequenceTable = new Array( weasel.FormatUltimateSoundTracker121.SequenceTableLength ); 88 89 for( var iLength = aPatternSequenceTable.length; --iLength >= 0; ) 90 aPatternSequenceTable[ iLength ] = 0; 91 92 for( var iPatternSequenceTable = weasel.FormatSpreadpointSoundTracker23.PatternSequenceTable, iNumberOfPatterns = weasel.FormatUltimateSoundTracker121.SequenceTableLength, iPattern = 0; iPattern < iNumberOfPatterns; iPattern++ ) 93 { 94 try 95 { 96 var iPatternNumber = weasel.Helper.getByte( this.aModuleData, iPatternSequenceTable++ ); 97 98 aPatternSequenceTable[ iPattern ] = iPatternNumber; 99 100 }catch (oException ) {} 101 } 102 103 return aPatternSequenceTable; 104 }; 105 106 107 // --------------------------------------------------------------------------- 108 /** 109 * Get the length of the M.K. 31 instrument Spreadpoint Soundtracker 2.3+ module in patterns. 110 * 111 * @return {int} = Length of song in patterns. 112 */ 113 weasel.SpreadpointSoundTracker23.prototype.getSongLengthInPatterns = function() 114 { 115 try 116 { 117 return weasel.Helper.getByte( this.aModuleData, weasel.FormatSpreadpointSoundTracker23.SongLength ); 118 }catch ( oException ) 119 { 120 return 0; 121 } 122 }; 123 124 // --------------------------------------------------------------------------- 125 /** Process a channel's effects. 126 * 127 * @param {weasel.Channel} oChannel = The Channel to process for effects. 128 * 129 * @protected 130 * @override 131 */ 132 weasel.SpreadpointSoundTracker23.prototype._processChannelEffect = function( oChannel ) 133 { 134 switch( oChannel.getEffectNumber() ) 135 { 136 case weasel.FormatDOCSoundTracker9.Effects.Arpeggio : 137 138 if( oChannel.getEffectParameter() == 0 ) 139 break; 140 141 oChannel.arpeggio( this.iCurrentTick, weasel.Channel.prototype.ArpeggioMode.UltimateSoundtracker ); 142 143 break; 144 145 case weasel.FormatDOCSoundTracker9.Effects.PitchbendUp : 146 147 oChannel.pitchBend( this.iCurrentTick, 0, oChannel.getEffectParameter() ); 148 oChannel.setShadowNotePeriod( this._clampNotePeriod( oChannel.getShadowNotePeriod() ) ); 149 oChannel.setNotePeriod( oChannel.getShadowNotePeriod() ); 150 151 break; 152 153 case weasel.FormatDOCSoundTracker9.Effects.PitchbendDown : 154 155 oChannel.pitchBend( this.iCurrentTick, oChannel.getEffectParameter(), 0 ); 156 oChannel.setShadowNotePeriod( this._clampNotePeriod( oChannel.getShadowNotePeriod() ) ); 157 oChannel.setNotePeriod( oChannel.getShadowNotePeriod() ); 158 159 break; 160 161 case weasel.FormatSpreadpointSoundTracker23.Effects.VolumeSlide : 162 163 oChannel.volumeSlide( this.iCurrentTick ); 164 165 break; 166 167 default : 168 break; 169 } 170 }; 171 172