Ejemplo n.º 1
0
//------------------------------------------------------------------------------
Wdt::Wdt( const BufferS_t &buffer ) {
  if ( buffer.size() <= 0 ) {
    quitApp( "[WDT] buffer invalid" );
    return;
  }

  // create an istream of our buffer
  std::stringbuf str_buf( buffer );
  std::istream i_str( &str_buf );

  uint32_t chunk_size = 0;
  // read in chunk by chunk
  chunk_size = readChunkHead( i_str, "MVER", (char*)&_mverChunk, sizeof( MverChunk_s ) );
  chunk_size = readChunkHead( i_str, "MPHD", (char*)&_mphdChunk, sizeof( MphdChunk_s ) );
  chunk_size = readChunkHead( i_str, "MAIN", (char*)&_mainChunk, sizeof( MainChunk_s ) );
  
  // I could just say 64*64, but it's there to check that everything went right
  size_t count = _mainChunk.size / sizeof( MainChunk_s::AsyncObject_s );
  size_t num_adts = 0;
  _asyncObjects.resize( count );

  // read flags from buffer
  for ( size_t i = 0; i < count; i++ ) {
    i_str.read( (char*)&_asyncObjects[i], sizeof( MainChunk_s::AsyncObject_s ) );
    
    if ( _asyncObjects[i].flags & 0x1 ) {
      num_adts++;
    }
  }

  _adtCoords.resize( num_adts );
  int i = 0;
  for ( int y = 0; y < 64; y++ ) {
    for ( int x = 0; x < 64; x++ ) {
      // get all tiles with flag & 1
      if ( _asyncObjects[y*64+x].flags & 0x1 ) {
        _adtCoords[i].x = x;
        _adtCoords[i].y = y;
        i++;
      }
    }
  }
}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
bool PGChunk::ReadDataToVP( InstParams *vp )
{
	while ( (mDataSize - mDataPos) > (int)sizeof( MyChunkHead ) ) {
		int		ckType;
		long	ckSize;
		readChunkHead(&ckType, &ckSize);
		switch (ckType) {
			case kAudioUnitCustomProperty_ProgramName:
				readData(vp->pgname, ckSize, &ckSize);
				break;
			case kAudioUnitCustomProperty_BRRData:
			{
				if ( vp->brr.data ) {
					delete [] vp->brr.data;
				}
				vp->brr.data = new unsigned char[ckSize];
				long	actSize;
				readData(vp->brr.data, ckSize, &actSize);
				vp->brr.size = actSize;
				vp->loop = vp->brr.data[actSize-9]&2?true:false;
				break;
			}
			case kAudioUnitCustomProperty_Rate:
				readData(&vp->rate, ckSize, NULL);
				break;
			case kAudioUnitCustomProperty_BaseKey:
				readData(&vp->basekey, ckSize, NULL);
				break;
			case kAudioUnitCustomProperty_LowKey:
				readData(&vp->lowkey, ckSize, NULL);
				break;
			case kAudioUnitCustomProperty_HighKey:
				readData(&vp->highkey, ckSize, NULL);
				break;
			case kAudioUnitCustomProperty_LoopPoint:
				readData(&vp->lp, ckSize, NULL);
				break;

			case kAudioUnitCustomProperty_AR:
				readData(&vp->ar, ckSize, NULL);
				break;
			case kAudioUnitCustomProperty_DR:
				readData(&vp->dr, ckSize, NULL);
				break;
			case kAudioUnitCustomProperty_SL:
				readData(&vp->sl, ckSize, NULL);
				break;
			case kAudioUnitCustomProperty_SR:
				readData(&vp->sr, ckSize, NULL);
				break;

            case kAudioUnitCustomProperty_SustainMode:
			{
				int value;
				readData(&value, ckSize, NULL);
				vp->sustainMode = value ? true:false;
				break;
			}
            
			case kAudioUnitCustomProperty_VolL:
				readData(&vp->volL, ckSize, NULL);
				break;
			case kAudioUnitCustomProperty_VolR:
				readData(&vp->volR, ckSize, NULL);
				break;
				
			case kAudioUnitCustomProperty_Echo:
			{
				int value;
				readData(&value, ckSize, NULL);
				vp->echo = value ? true:false;
				break;
			}
			case kAudioUnitCustomProperty_Bank:
				readData(&vp->bank, ckSize, NULL);
				break;
				
            case kAudioUnitCustomProperty_MonoMode:
			{
				int value;
				readData(&value, ckSize, NULL);
				vp->monoMode = value ? true:false;
				break;
			}
            
            case kAudioUnitCustomProperty_PortamentoOn:
			{
				int value;
				readData(&value, ckSize, NULL);
				vp->portamentoOn = value ? true:false;
				break;
			}
                
            case kAudioUnitCustomProperty_PortamentoRate:
				readData(&vp->portamentoRate, ckSize, NULL);
				break;
                
            case kAudioUnitCustomProperty_NoteOnPriority:
				readData(&vp->noteOnPriority, ckSize, NULL);
				break;
                
            case kAudioUnitCustomProperty_ReleasePriority:
				readData(&vp->releasePriority, ckSize, NULL);
				break;
                
			case kAudioUnitCustomProperty_IsEmaphasized:
			{
				int value;
				readData(&value, ckSize, NULL);
				vp->isEmphasized = value ? true:false;
				break;
			}
			case kAudioUnitCustomProperty_SourceFileRef:
				readData(vp->sourceFile, ckSize, &ckSize);
				break;
			default:
				//不明チャンクの場合は飛ばす
				AdvDataPos(ckSize);
				break;
		}
	}
	return true;
}