Ejemplo n.º 1
0
bool CInstrumentEditorDPCM::LoadSample(CString FilePath, CString FileName)
{
	CFile SampleFile;

	if (!SampleFile.Open(FilePath, CFile::modeRead)) {
		AfxMessageBox(IDS_FILE_OPEN_ERROR);
		return false;
	}

	CDSample *pNewSample = new CDSample();

	if (pNewSample != NULL) {
      strcpy(pNewSample->Name, (char*)FileName.GetString());
		int Size = (int)SampleFile.GetLength();
		int AddSize = 0;
		// Clip file if too large
		Size = min(Size, CDSample::MAX_SIZE);
		// Make sure size is compatible with DPCM hardware
		if ((Size & 0xF) != 1) {
			AddSize = 0x10 - ((Size + 0x0F) & 0x0F);
		}
		pNewSample->SampleSize = Size + AddSize;
		pNewSample->SampleData = new char[Size + AddSize];
		SampleFile.Read(pNewSample->SampleData, Size);
		memset(pNewSample->SampleData + Size, 0xAA, AddSize);
		if (!InsertSample(pNewSample))
			return false;
	}
	
	SampleFile.Close();
	BuildSampleList();

	return true;
}
Ejemplo n.º 2
0
BOOL CInstrumentEditorDPCM::OnInitDialog()
{
	CInstrumentEditPanel::OnInitDialog();

	CString Text;

	m_iOctave = 3;
	m_iSelectedKey = 0;

	CComboBox *pPitch  = reinterpret_cast<CComboBox*>(GetDlgItem(IDC_PITCH));
	CComboBox *pOctave = reinterpret_cast<CComboBox*>(GetDlgItem(IDC_OCTAVE));

	m_pTableListCtrl = reinterpret_cast<CListCtrl*>(GetDlgItem(IDC_TABLE));
	m_pTableListCtrl->DeleteAllItems();
	m_pTableListCtrl->InsertColumn(0, _T("Key"), LVCFMT_LEFT, 30);
	m_pTableListCtrl->InsertColumn(1, _T("Pitch"), LVCFMT_LEFT, 35);
	m_pTableListCtrl->InsertColumn(2, _T("Sample"), LVCFMT_LEFT, 90);
	m_pTableListCtrl->SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);

	m_pSampleListCtrl = reinterpret_cast<CListCtrl*>(GetDlgItem(IDC_SAMPLE_LIST));
	m_pSampleListCtrl->DeleteAllItems();
	m_pSampleListCtrl->InsertColumn(0, _T("#"), LVCFMT_LEFT, 22);
	m_pSampleListCtrl->InsertColumn(1, _T("Name"), LVCFMT_LEFT, 88);
	m_pSampleListCtrl->InsertColumn(2, _T("Size"), LVCFMT_LEFT, 39);
	m_pSampleListCtrl->SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);

	for (int i = 0; i < 16; ++i) {
		Text.Format(_T("%i"), i);
		pPitch->AddString(Text);
	}

	pPitch->SetCurSel(15);

	for (int i = 0; i < OCTAVE_RANGE; ++i) {
		Text.Format(_T("%i"), i);
		pOctave->AddString(Text);
	}

	pOctave->SetCurSel(3);
	CheckDlgButton(IDC_LOOP, 0);
	m_pTableListCtrl->DeleteAllItems();

	for (int i = 0; i < 12; ++i)
		m_pTableListCtrl->InsertItem(i, KEY_NAMES[i], 0);

	BuildSampleList();
	m_iSelectedSample = 0;

	CSpinButtonCtrl *pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_DELTA_SPIN);
	pSpin->SetRange(-1, 127);
	pSpin->SetPos(-1);

	SetDlgItemText(IDC_DELTA_COUNTER, _T("Off"));

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 3
0
void CInstrumentEditorDPCM::OnBnClickedImport()
{
	CPCMImport	ImportDialog;
	CDSample	*pImported;

	if (!(pImported = ImportDialog.ShowDialog()))
		return;

	InsertSample(pImported);
	BuildSampleList();
}
Ejemplo n.º 4
0
void CInstrumentEditorDPCM::OnBnClickedEdit()
{
	CDSample *pSample = GetSelectedSample();

	if (pSample == NULL)
		return;

	CSampleEditorDlg Editor(this, pSample);

	INT_PTR nRes = Editor.DoModal();
	
	if (nRes == IDOK) {
		// Save edited sample
		Editor.CopySample(pSample);
	}

	// Update sample list
	BuildSampleList();
}
Ejemplo n.º 5
0
void CInstrumentEditorDPCM::OnBnClickedUnload()
{
	CListCtrl *pListBox = (CListCtrl*)GetDlgItem(IDC_SAMPLE_LIST);
	int nItem(-1), SelCount, Index;
	char ItemName[256];

	if (m_iSelectedSample == MAX_DSAMPLES)
		return;
	
	if (!(SelCount = pListBox->GetSelectedCount()))
		return;

	for (int i = 0; i < SelCount; i++) {
		nItem = pListBox->GetNextItem(nItem, LVNI_SELECTED);
		ASSERT(nItem != -1);
		pListBox->GetItemText(nItem, 0, ItemName, 256);
		Index = atoi(ItemName);
		GetDocument()->RemoveDSample(Index);
	}

	BuildSampleList();
}