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 /** Object to contain a single cell of pattern data (4 cells per pattern row).
  9  * 
 10  * @constructor
 11  * @param {int} iPatternCellData = The pattern cell data as a 32bit integer which takes the form nnnniedd, n = note, i = instrument number, e = effect number, d = effect data.
 12  * 
 13  * @author Warren Willmey 2011
 14  */
 15 weasel.PatternCell = function( iPatternCellData ){
 16 	
 17 	this.iNotePeriod			= 0;
 18 	this.iInstrumentNumber		= 0;
 19 	this.iEffectNumber			= 0;
 20 	this.iEffectParameterValue	= 0;
 21 	
 22 	this.setCell( iPatternCellData );
 23 };
 24 
 25 // ---------------------------------------------------------------------------
 26 /**
 27  * Set the pattern cell data for this cell.
 28  * 
 29  * @param {int} iPatternCellData = In format of 0x12345678 where:
 30  *   0x1234 = note period value
 31  * , 0x5    = instrument number
 32  * , 0x6    = effect number
 33  * , 0x78   = effect parameter.
 34  */
 35 weasel.PatternCell.prototype.setCell = function( iPatternCellData )
 36 {
 37 	this.iNotePeriod			= (iPatternCellData >>> 16) & 0xffff;
 38 	this.iInstrumentNumber		= (iPatternCellData >>> 12) & 0xf;
 39 	this.iEffectNumber			= (iPatternCellData >>>  8) & 0xf;
 40 	this.iEffectParameterValue	=  iPatternCellData & 0xff;
 41 };
 42 
 43 
 44 // ---------------------------------------------------------------------------
 45 /**
 46  * Get the Amiga note period of the current pattern cell.
 47  * 
 48  * @return {int} = The Amiga note period stored in this cell (0 = no note).
 49  */
 50 weasel.PatternCell.prototype.getNotePeriod = function()
 51 {
 52 	return this.iNotePeriod;
 53 };
 54 
 55 
 56 // ---------------------------------------------------------------------------
 57 /**
 58  * Get the instrument number from the current pattern cell.
 59  * 
 60  * @return {int} = The instrument number stored in this cell (0-15 range, 0 = no instrument number).
 61  */
 62 weasel.PatternCell.prototype.getInstrumentNumber = function()
 63 {
 64 	return this.iInstrumentNumber;
 65 };
 66 
 67 
 68 // ---------------------------------------------------------------------------
 69 /**
 70  * Get the effect number from the current pattern cell.
 71  * 
 72  * @return {int} = The effect number stored in this cell (0-2 range, 0 = no effect, 1 = arpeggio, 2 = pitch bend).
 73  */
 74 weasel.PatternCell.prototype.getEffectNumber = function()
 75 {
 76 	return this.iEffectNumber;
 77 };
 78 
 79 // ---------------------------------------------------------------------------
 80 /**
 81  * Get the effect parameter value from the current pattern cell.
 82  * 
 83  * @return {int} = The effect parameter value in this cell (Its meaning depends on the Effect Number).
 84  */
 85 weasel.PatternCell.prototype.getEffectParameter = function()
 86 {
 87 	return this.iEffectParameterValue;
 88 };
 89 
 90 
 91