bool CaptureManager::SaveVolumeData(const char* file) { std::ofstream outfile; outfile.open(file, std::ofstream::out); if (!outfile) { wxLogError(_T("Unable to open file %s"), file); return false; } int numContours = Access(0,0,false)->contourArray.size(); outfile << "#width: " << size.width << ", height: " << size.height << ", frameCount: " << frameCount << ", fps: " << fps << std::endl; outfile << "#cellCount: " << numContours << std::endl; for (int c=0; c<numContours; c++) { CvSeq *oseq = Access(0,0,false)->contourArray[c]; int np = oseq->total; float avgVolume; std::vector<double> volumes = GetVolumes(c, avgVolume); outfile << "#Cell: " << c+1 << ", pointCount: " << np << ", avgVolume: " << avgVolume << std::endl; for (int i=0; i<volumes.size(); i++) { outfile << volumes[i] << std::endl;; } } outfile.close(); return true; }
void GetProcessedBuffer(void* abuf,unsigned int length,int channel) { short* buf=(short*) abuf; //Control Volume if (channels[channel].effects[PSPAALIB_EFFECT_STEREO_BY_POSITION]) { channels[channel].volume=GetVolumes(channels[channel].position,observerPosition,observerFront); } else if(!channels[channel].effects[PSPAALIB_EFFECT_VOLUME_MANUAL]) { channels[channel].volume=(AalibVolume){1.0f,1.0f}; } if (channels[channel].effects[PSPAALIB_EFFECT_STRENGTH_BY_POSITION]) { channels[channel].audioStrength=GetStrengthByPosition(channels[channel].position,observerPosition); } else { channels[channel].audioStrength=1.0f; } //Control Play Speed if (channels[channel].effects[PSPAALIB_EFFECT_DOPPLER]) { channels[channel].playSpeed=GetDopplerPlaySpeed(channels[channel].position,channels[channel].velocity,observerPosition,observerVelocity); } else if (!channels[channel].effects[PSPAALIB_EFFECT_PLAYSPEED]) { channels[channel].playSpeed=1.0f; } if (!channels[channel].effects[PSPAALIB_EFFECT_AMPLIFY]) { channels[channel].ampValue=1.0f; } //Get Buffer if ((channels[channel].effects[PSPAALIB_EFFECT_PLAYSPEED])||(channels[channel].effects[PSPAALIB_EFFECT_DOPPLER])||(channels[channel].effects[PSPAALIB_EFFECT_MIX])) { short* tempBuf; tempBuf=malloc((int)(length*channels[channel].playSpeed*2*sizeof(short))); GetRawBuffer(tempBuf,length*channels[channel].playSpeed,channels[channel].ampValue,channel); GetBufferSpeedEffect(buf,tempBuf,length,channels[channel].playSpeed,channels[channel].effects[PSPAALIB_EFFECT_MIX]); free(tempBuf); } else { GetRawBuffer(buf,length,channels[channel].ampValue,channel); } }
std::vector<double> CaptureManager::GetVolumeDiff(int c, float &avgDiff) { std::vector<double> v = GetVolumes(c, avgDiff); std::vector<double> diff(frameCount-1, 0.0); double totalDiff = 0; int goodSteps = 0; for (int i=0; i<frameCount-1; i++) { if (Access(i,0, false, true)->contourArray.size() > c) { goodSteps++; totalDiff += (diff[i] = v[i+1]-v[i]); } } avgDiff = (goodSteps ? totalDiff/goodSteps : 0); return diff; }
static int Boot(enum boot_settings settings) { int result=0; int opened; OSD_Puts("Initializing SD card\n"); if(spi_init()) { int dipsw=GetDIPSwitch(); if(!FindDrive()) return(0); if(sd_ishc()) { OSD_Puts("SDHC not supported;"); OSD_Puts("\ndisabling SD card\n\x10 OK\n"); WaitEnter(); dipsw|=4; // Disable SD card. HW_HOST(HW_HOST_CTRL)=HW_HOST_CTRLF_RESET; // Put OCMSX into Reset again HW_HOST(HW_HOST_SW)=dipsw; SetDIPSwitch(dipsw); } else if(IsFat32()) { OSD_Puts("Fat32 not supported;"); OSD_Puts("\ndisabling SD card\n\x10 OK\n"); WaitEnter(); dipsw|=4; // Disable SD card. HW_HOST(HW_HOST_CTRL)=HW_HOST_CTRLF_RESET; // Put OCMSX into Reset again HW_HOST(HW_HOST_SW)=dipsw; SetDIPSwitch(dipsw); } HW_HOST(HW_HOST_CTRL)=HW_HOST_CTRLF_SDCARD; // Release reset but steal SD card if(opened=FileOpen(&file,"OCMSX CFG")) // Do we have a configuration file? { if(settings==BOOT_SAVESETTINGS) // If so, are we saving to it, or loading from it? { int i; int *p=(int *)sector_buffer; *p++=dipsw; *p++=GetVolumes(); *p++=GetMouseSettings(); for(i=0;i<125;++i) // Clear remainder of buffer *p++=0; FileWrite(&file,sector_buffer); } else if(settings==BOOT_LOADSETTINGS) { FileRead(&file,sector_buffer); dipsw=*(int *)(§or_buffer[0]); SetVolumes(*(int *)(§or_buffer[4])); SetMouseSettings(*(int *)(§or_buffer[8])); HW_HOST(HW_HOST_SW)=dipsw; SetDIPSwitch(dipsw); } // printf("DIP %d, Vol %d\n",dipsw,GetVolumes()); } OSD_Puts("Trying MSX3BIOS.SYS\n"); if(!(opened=FileOpen(&file,"MSX3BIOSSYS"))) // Try and load MSX3 BIOS first { OSD_Puts("Trying BIOS_M2P.ROM\n"); opened=FileOpen(&file,"BIOS_M2PROM"); // If failure, load MSX2 BIOS. } if(opened) { OSD_Puts("Loading BIOS\n"); int filesize=file.size; unsigned int c=0; int bits; bits=0; c=filesize; while(c) { ++bits; c>>=1; } bits-=9; while(filesize>0) { OSD_ProgressBar(c,bits); if(FileRead(&file,sector_buffer)) { int i; int *p=(int *)§or_buffer; for(i=0;i<(filesize<512 ? filesize : 512) ;i+=4) { int t=*p++; int t1=t&255; int t2=(t>>8)&255; int t3=(t>>16)&255; int t4=(t>>24)&255; HW_HOST(HW_HOST_BOOTDATA)=t4; HW_HOST(HW_HOST_BOOTDATA)=t3; HW_HOST(HW_HOST_BOOTDATA)=t2; HW_HOST(HW_HOST_BOOTDATA)=t1; } } else { OSD_Puts("Read failed\n"); return(0); } FileNextSector(&file); filesize-=512; ++c; } HW_HOST(HW_HOST_CTRL)=HW_HOST_CTRLF_BOOTDONE; // Release SD card and early-terminate any remaining requests for boot data return(1); }