Example #1
0
//---------------------------------------------------------------------------
// ファイルのロード
int __fastcall TResCmpDlg::LoadResFile(LPCSTR pName)
{
	FILE		*fp;
	char		bf[32];

	if( (fp = fopen(pName, "rb"))!=NULL ){
		fread(bf, 1, 16, fp);
		if( strcmp(bf, RESSTR) ){
			ErrorMB(ILLFMT, pName);
			fclose(fp);
			return FALSE;// フォーマット異常
		}
		ANTDEF *ap = new ANTDEF;
		ENVDEF *ep = new ENVDEF;
		memcpy(ep, &env, sizeof(ENVDEF));
		AnsiString rem;
		ReadAntFromFp(ap, rem, fp);
		delete ap;
		memcpy(&env, ep, sizeof(ENVDEF));
		delete ep;
		Res[Cnt].LoadCurData(fp);
		Cnt++;
		fclose(fp);
		return TRUE;
	}
	else {
		ErrorMB("'%s'が見つかりません.", pName);
	}
	return FALSE;
}
Example #2
0
BOOL __fastcall CWaveFile::Play(LPCSTR pName)
{
	FileClose();
	FILE *fp = fopen(pName, "rb");
	if( fp == NULL ){
		ErrorMB( sys.m_MsgEng?"Can't open '%s'":"'%s'をオープンできません.", pName);
		return FALSE;
	}
	m_length = filelength(fileno(fp));
	m_FileName = pName;
    GetFileName(m_Name, pName);

	fclose(fp);
	m_Handle = mmioOpen(m_FileName.c_str(), NULL, MMIO_READ|MMIO_ALLOCBUF);
	if( m_Handle == NULL ){
		ErrorMB( sys.m_MsgEng?"Can't open '%s'":"'%s'をオープンできません.", pName);
		return FALSE;
	}
	m_pos = 0;
	if( mmioRead(m_Handle, (char *)m_Head, 4) == 4 ){
		int type = 0;
		if( (m_Head[0] == 0x55)&&(m_Head[1] == 0xaa) ){
			type = m_Head[2];
			m_pos = 4;
			m_length -= 4;
		}
		if( type > 10 ) type = 0;
		if( type != SAMPTYPE ){
			if( YesNoMB(
				sys.m_MsgEng
				? "%s\r\n\r\nThis file has been recorded based on %uHz, play it with sampling conversion?\r\n\r\nThis conversion needs long time..."
				: "%s\r\n\r\nこのファイルは %uHz ベースで記録されています. 周波数変換して再生しますか?\r\n\r\nこの変換は時間がかかる場合があります...",
				m_FileName.c_str(), g_tSampTable[type] ) == IDNO ){
				mmioClose(m_Handle, 0);
				m_Handle = 0;
				return FALSE;
			}
			else {
				mmioClose(m_Handle, 0);
				m_Handle = 0;
				char bf[1024];
				strcpy(bf, pName);
				SetEXT(bf, "");
				char wName[1024];
				sprintf(wName, "%s_%u.MMV", bf, int(SAMPBASE));
				if( ChangeSampFreq(wName, pName, g_tSampTable[type]) == TRUE ){
					Play(wName);
				}
			}
		}
	}
	m_mode = 1;
	m_pause = 0;
	m_dis = 0;
	return TRUE;
}
Example #3
0
//---------------------------------------------------------------------------
void __fastcall TFileEdit::Execute(LPCSTR pName, BOOL fReadOnly)
{
    DWORD dw = ::GetFileAttributes(pName);
    if( (dw != 0xffffffff) && (dw & FILE_ATTRIBUTE_READONLY) ) {
        fReadOnly = TRUE;
    }
    REdit->ReadOnly = fReadOnly;
    AnsiString as = pName;
    if( fReadOnly ) as += sys.m_MsgEng ? " (Read only)" : " (読み取り専用)";
    Caption = as;
    CWaitCursor tw;
    m_FileName = pName;
    OnWave();
    try {
        REdit->Lines->LoadFromFile(pName);
    }
    catch(...) {
        FILE *fp;
        if( (fp = fopen(pName, "rt")) != NULL ) {
            OnWave();
            char bf[2048];
            REdit->Lines->Clear();
            while(!feof(fp)) {
                if( fgets(bf, sizeof(bf), fp) ) {
                    ClipLF(bf);
                    REdit->Lines->Add(bf);
                }
            }
            fclose(fp);
            REdit->ReadOnly = TRUE;
        }
        else {
            ErrorMB(sys.m_MsgEng ? "Sorry, could not open <%s>...":"<%s>をオープンできませんでした", pName);
            Close();
            return;
        }
    }
    if( m_fDelFile ) {
        m_fDelFile = FALSE;
        unlink(pName);
    }
    REdit->Modified = FALSE;
    m_InitFirst = FALSE;
    OnWave();
    AdjustTop();
    Show();
    if( !::IsWindowEnabled(Handle) ) ::EnableWindow(Handle, TRUE);
}
Example #4
0
void __fastcall CWaveFile::Rec(LPCSTR pName)
{
	FileClose();
	m_FileName = pName;
    GetFileName(m_Name, pName);
	m_Handle = mmioOpen(m_FileName.c_str(), NULL, MMIO_CREATE|MMIO_WRITE|MMIO_ALLOCBUF);
	if( m_Handle == NULL ){
		ErrorMB( sys.m_MsgEng?"Can't open '%s'":"'%s'を作成できません.", pName);
		return;
	}
	m_Head[0] = 0x55;
	m_Head[1] = 0xaa;
	m_Head[2] = char(SAMPTYPE);
	m_Head[3] = 0;
	mmioWrite(m_Handle, (const char *)m_Head, 4);
	m_pos = 4;
	m_mode = 2;
	m_pause = 0;
	m_dis = 0;
}