/// <summary> /// Loads all patterns of a modfile and converts them into the /// 3 byte format. /// </summary> /// <returns></returns> public virtual bool ML_LoadPatterns(int patternsCount) { int t, s = 0; this._module.Patterns = new System.Collections.Generic.List <Pattern>(patternsCount); // Allocate temporary buffer for loading and converting the patterns patbuf = new MODNOTE[64 * this._module.ChannelsCount]; for (t = 0; t < 64 * this._module.ChannelsCount; t++) { patbuf[t] = new MODNOTE(); patbuf[t].a = (short)(patbuf[t].b = (short)(patbuf[t].c = (short)(patbuf[t].d = 0))); } for (t = 0; t < patternsCount; t++) { if (this.AllocPatterns != null && !AllocPatterns(_module, t, 64)) { return(false); } if (this.AllocTracks != null && !AllocTracks(this._module.Patterns[t], _module.ChannelsCount)) { return(false); } // Load the pattern into the temp buffer and convert it for (s = 0; s < (int)(64 * this._module.ChannelsCount); s++) { patbuf[s].a = Reader.ReadUByte(); patbuf[s].b = Reader.ReadUByte(); patbuf[s].c = Reader.ReadUByte(); patbuf[s].d = Reader.ReadUByte(); } for (s = 0; s < this._module.ChannelsCount; s++) { if ((this._module.Patterns[t].Tracks[s].UniTrack = ConvertTrack(patbuf, s)) == null) { return(false); } } } return(true); }
public virtual void ConvertNote(MODNOTE n) { short instrument, effect, effdat, note; int period; /* extract the various information from the 4 bytes that * make up a single note */ instrument = (short)((n.a & 0x10) | (n.c >> 4)); period = (((int)n.a & 0xf) << 8) + n.b; effect = (short)(n.c & 0xf); effdat = n.d; /* Convert the period to a note number */ note = 0; if (period != 0) { for (note = 0; note < 60; note++) { if (period >= npertab[note]) { break; } } note++; if (note == 61) { note = 0; } } if (instrument != 0) { this.UniTrack.UniInstrument((short)(instrument - 1)); } if (note != 0) { this.UniTrack.UniNote((short)(note + 23)); } this.UniTrack.UniPTEffect(effect, effdat); }