public class CStanza {// Members CSection m_psecParent; CLayer m_arrpLayers[]; int m_iNumLayers; int m_iNumLayersAllocated; CCompoundMusicLine m_arrpCMLines[]; int m_iNumLines; int m_iNumLinesAllocated; int m_iMaxNumLines; //======bogus global functions===== public int mod (int x, int y) { if (x>=0) return x%y; int iNegMod = (-x) % y; return (0==iNegMod) ? y-iNegMod : 0; } public void assert(boolean b) { if (!b) m_arrpCMLines[-1] = null; } public int rand() { return (int)(Math.random() * 9747); } //================================ CStanza (CSection psecParent) { m_arrpLayers=null; m_iNumLayers=0; m_iNumLayersAllocated=0; m_arrpCMLines=null; m_iNumLines=0; m_iNumLinesAllocated=0; m_iMaxNumLines=0; m_psecParent=psecParent; } //---------------------------- // Call one of these after creation and before use: public void Initialize (CRhythm pRthm, int iMaxLines/*=4*/, int iTempo/*=3*/) { m_iMaxNumLines = iMaxLines; assert(0==m_iNumLayers); AppendNewLayer(pRthm,true); bSetCurrTempo(iTempo,-1); } //---------------------------- public void Initialize2 (CStanza pstz, int iMaxLines/*=4*/) { m_iMaxNumLines = iMaxLines; assert(0==m_iNumLayers); for (int C=0; C= 0) { assert(iLayerNum < m_iNumLayers); m_arrpLayers[iLayerNum].pRhythm().SetTempo((char)iNewTempo); return true; } for (int C=0; C= 0) { assert(iLayerIndex < m_iNumLayers); return m_arrpLayers[iLayerIndex].pRhythm().bSet(szRthm); } for (int C=0; C= 0) { assert(iLayerIndex < m_iNumLayers); return m_arrpLayers[iLayerIndex].bSetRhythm(pRthm); } for (int C=0; C 1) pRthm = m_arrpLayers[0].pRhythm(); else pRthm = m_psecParent.pGetRhythm(0); } assert(null!=pRthm); m_arrpLayers[m_iNumLayers-1] = new CLayer(this, pRthm); m_arrpLayers[m_iNumLayers-1].bSetChordMatch(m_iNumLayers!=1); m_arrpLayers[m_iNumLayers-1].bSetActive(bActive); } // Implementation //---------------------------- void AppendNewLine () { if (m_iNumLines == m_iNumLinesAllocated) { m_iNumLinesAllocated += 6; CCompoundMusicLine[] temp = m_arrpCMLines; m_arrpCMLines = new CCompoundMusicLine[m_iNumLinesAllocated]; for (int C=0; C= 0 && sec.g_lmTestMel.pCopyLine.pvGetCenterNote() < 128); int iCopyLen = sec.g_lmTestMel.pCopyLine.iGetNumNotesPlayed(); if (iCopyLen == 0) iCopyLen = 1; sec.g_lmTestMel.iCopyIndex = (int)(iCopyLen-1-(1-fCoh)*(rand() % iCopyLen)); sec.g_lmTestMel.iCLOffset = iOff; } } else sec.g_lmTestMel.pCopyLine = null; // Reset from prev val. } } // end class