Beispiel #1
0
void RecSrcOut(COMMAND_T* = NULL)
{
	// Set the rec source to output
	// Set to mono or stereo based on first item
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		int iMode = 1; // 5 = mono, 1 = stereo
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		if (*(int*)GetSetMediaTrackInfo(tr, "I_SELECTED", NULL))
		{
			if (GetTrackNumMediaItems(tr))
			{
				MediaItem* mi = GetTrackMediaItem(tr, 0);
				if (GetMediaItemNumTakes(mi))
				{
					MediaItem_Take* mit = GetMediaItemTake(mi, 0);
					PCM_source* p = (PCM_source*)GetSetMediaItemTakeInfo(mit, "P_SOURCE", NULL);
					if (p && p->GetNumChannels() == 1)
						iMode = 5;

				}
			}
			GetSetMediaTrackInfo(tr, "I_RECMODE", &iMode);
		}
	}
}
Beispiel #2
0
bool RprTake::isMIDI()
{
    PCM_source *source = getSource();
    if (!source)
    {
        return false;
    }
    std::string takeType(source->GetType());
    return takeType == "MIDI" || takeType == "MIDIPOOL";
}
Beispiel #3
0
bool RprTake::isFile()
{
    PCM_source *source = getSource();
    if (!source)
    {
        return false;
    }
    std::string fileName(source->GetFileName());
    return !fileName.empty();
}
Beispiel #4
0
bool TakeFilenameMatch(MediaItem_Take* _tk, const char* _searchStr)
{
	bool match = false;
	PCM_source* src = _tk ? (PCM_source*)GetSetMediaItemTakeInfo(_tk, "P_SOURCE", NULL) : NULL;
	if (src) 
	{
		const char* takeFilename = src->GetFileName();
		match = (takeFilename && strstr(takeFilename, _searchStr)); // no stristr: osx + utf-8
	}
	return match;
}
Beispiel #5
0
void DoDeleteItemAndMedia(COMMAND_T*)
{
	MediaItem *CurItem;
	MediaItem_Take *CurTake;
	MediaTrack *CurTrack;
	Main_OnCommand(40100,0); // set all media offline
	for (int i=0;i<GetNumTracks();i++)
	{
		CurTrack=CSurf_TrackFromID(i+1,false);
		for (int j=0;j<GetTrackNumMediaItems(CurTrack);j++)
		{
			CurItem=GetTrackMediaItem(CurTrack,j);
			bool IsSel=*(bool*)GetSetMediaItemInfo(CurItem,"B_UISEL",NULL);
			if (IsSel==true)
			{
				for (int k = 0; k < GetMediaItemNumTakes(CurItem); k++)
				{
					CurTake=GetMediaItemTake(CurItem,k);
					PCM_source *CurPCM;
					CurPCM=(PCM_source*)GetSetMediaItemTakeInfo(CurTake,"P_SOURCE",NULL);
					if (CurPCM && CurPCM->GetFileName() && FileExists(CurPCM->GetFileName()))
					{
						char buf[2000];
						sprintf(buf,__LOCALIZE_VERFMT("Do you really want to immediately delete file (NO UNDO) %s?","sws_mbox"),CurPCM->GetFileName());

						int rc=MessageBox(g_hwndParent,buf,__LOCALIZE("Xenakios - Info","sws_mbox"),MB_OKCANCEL);
						if (rc==IDOK)
						{
							DeleteFile(CurPCM->GetFileName());
							char fileName[512];
							strcpy(fileName, CurPCM->GetFileName());
							char* pEnd = fileName + strlen(fileName);
							strcpy(pEnd, ".reapeaks");
							DeleteFile(fileName);
							strcpy(pEnd, ".reapindex");
							DeleteFile(fileName);
						}
					}
				}
			}
		}
	}
	Main_OnCommand(40006,0); // remove selected items
	Main_OnCommand(40101,0); // set all media online
}
Beispiel #6
0
void UnselNotRender(COMMAND_T* = NULL)
{
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			if (GetMediaItemNumTakes(mi))
			{
				PCM_source* src = (PCM_source*)GetSetMediaItemTakeInfo(GetMediaItemTake(mi, -1), "P_SOURCE", NULL);
				if (src && src->GetFileName() && !strstr(src->GetFileName(), "render"))
					GetSetMediaItemInfo(mi, "B_UISEL", &g_bFalse);
			}
		}
	}
	UpdateTimeline();
}
Beispiel #7
0
void DoDelSelItemAndSendActiveTakeMediaToRecycler(COMMAND_T*)
{
	MediaItem *CurItem;
	MediaItem_Take *CurTake;
	MediaTrack *CurTrack;
	Main_OnCommand(40100,0); // set all media offline
	for (int i=0;i<GetNumTracks();i++)
	{
		CurTrack=CSurf_TrackFromID(i+1,false);
		for (int j=0;j<GetTrackNumMediaItems(CurTrack);j++)
		{
			CurItem=GetTrackMediaItem(CurTrack,j);
			bool IsSel=*(bool*)GetSetMediaItemInfo(CurItem,"B_UISEL",NULL);
			if (IsSel==true)
			{
				for (int k=0; k < GetMediaItemNumTakes(CurItem); k++)
				{
					CurTake=GetMediaItemTake(CurItem,k);
					PCM_source* CurPCM = (PCM_source*)GetSetMediaItemTakeInfo(CurTake,"P_SOURCE",NULL);
					if (CurPCM && CurPCM->GetFileName() && FileExists(CurPCM->GetFileName()))
					{
						SendFileToRecycleBin(CurPCM->GetFileName());
						char fileName[512];
						strcpy(fileName, CurPCM->GetFileName());
						char* pEnd = fileName + strlen(fileName);
						strcpy(pEnd, ".reapeaks");
						SendFileToRecycleBin(fileName);
						strcpy(pEnd, ".reapindex");
						SendFileToRecycleBin(fileName);
					}
				}
			}
		}
	}
	Main_OnCommand(40006,0); // remove selected items
	Main_OnCommand(40101,0); // set all media online
}
Beispiel #8
0
void DoRubberBandProcessing()
{
	char ExeLine[2048];
	double PitchFactor=pow(2.0,g_RubberBandParams.PitchSemis/12.0);


	MediaTrack* MunRaita;
	MediaItem* CurItem;
	MediaItem_Take* CurTake;
	PCM_source *ThePCMSource;
	int numItems=666;

	bool ItemSelected=false;

	bool NewSelectedStatus=false;
	bool FirstSelFound=false;
	Undo_BeginBlock();
	Main_OnCommand(40601,0); // render items to new take

	for (int i=0;i<GetNumTracks();i++)
	{
		MunRaita = CSurf_TrackFromID(i+1,FALSE);
		numItems=GetTrackNumMediaItems(MunRaita);

		for (int j=0;j<numItems;j++)
		{
			CurItem = GetTrackMediaItem(MunRaita,j);
			ItemSelected=*(bool*)GetSetMediaItemInfo(CurItem,"B_UISEL",NULL);
			if (ItemSelected==TRUE)
			{
				if (GetMediaItemNumTakes(CurItem)>0)
				{
					CurTake=GetMediaItemTake(CurItem,-1);

					double NewVol=1.0;
					FirstSelFound=true;

					ThePCMSource=(PCM_source*)GetSetMediaItemTakeInfo(CurTake,"P_SOURCE",NULL);
					if (!ThePCMSource || !ThePCMSource->GetFileName())
						break;

					char ProjectPath[1024];
					char RenderOutName[1024];
					GetProjectPath(ProjectPath,1024);
					char OriginalSourceFileName[1024];
					char OrigFullFileName[1024];
					strcpy(OrigFullFileName, ThePCMSource->GetFileName());
					ExtractFileNameEx(OrigFullFileName,OriginalSourceFileName,true);

					for (int x = 1; x < 1000; x ++)
					{
						sprintf(RenderOutName,"%s\\%s %03d.wav",ProjectPath, OriginalSourceFileName,x);
						if (!FileExists(RenderOutName))
							break;
					}

					sprintf(ExeLine,"%s\\Plugins\\rubberband.exe -c%d -t%f -f%f \"%s\" \"%s\"",GetExePath(),g_RubberBandParams.Mode,
						g_RubberBandParams.StretchFactor,PitchFactor,ThePCMSource->GetFileName(),RenderOutName);
					STARTUPINFO          si = { sizeof(si) };
					PROCESS_INFORMATION  pi;
					if(CreateProcess(0, ExeLine, 0, 0, FALSE, 0, 0, 0, &si, &pi))
					{
						DWORD TheResult;
						// optionally wait for process to finish
						TheResult=WaitForSingleObject(pi.hProcess, 60000); // max 60 seconds to wait for processing to complete
						if (TheResult==WAIT_TIMEOUT)
						{
							// RubberBand processed too long
							//CsoundSuccesfull=false;
						}
						CloseHandle(pi.hProcess);
						CloseHandle(pi.hThread);
						char OldTakeName[2048];
						strcpy(OldTakeName,(char*)GetSetMediaItemTakeInfo(CurTake,"P_NAME",NULL));
						Main_OnCommand(40440,0); // selected item medias offline
						DeleteFile(ThePCMSource->GetFileName());
						Main_OnCommand(40129,0); // delete current take from item
						// 40439
						//int CurTakeIndex=*(int*)GetSetMediaItemInfo(CurItem,"I_CURTAKE",NULL);
						int LastTakeIndex=GetMediaItemNumTakes(CurItem);
						MediaItem_Take *NewMediaTake=AddTakeToMediaItem(CurItem);
						PCM_source *NewPCMSource=PCM_Source_CreateFromFile(RenderOutName);
						NewPCMSource->Peaks_Clear(true);
						//ProjectStateContext ctx;
						//NewPCMSource->LoadState
						GetSetMediaItemTakeInfo(NewMediaTake,"P_SOURCE",NewPCMSource);
						//GetSetMediaItemInfo(CurItem,"I_CURTAKE",&LastTake);
						//GetSetMediaItemInfo(CurItem,"D_LENGTH",&OutDur);
						char BetterTakeName[512];

						sprintf(BetterTakeName,"%s_RB_%d_%.2fx_%.2fsemitones",OldTakeName,g_RubberBandParams.Mode, g_RubberBandParams.StretchFactor,g_RubberBandParams.PitchSemis);
						GetSetMediaItemTakeInfo(NewMediaTake,"P_NAME",BetterTakeName);
						GetSetMediaItemInfo(CurItem,"I_CURTAKE",&LastTakeIndex);
						Main_OnCommand(40047,0); // build any missing peaks
						Main_OnCommand(40612,0); // set item length to source media len
						Main_OnCommand(40439,0); // set selected media online
						SetForegroundWindow(g_hwndParent);
						//Undo_OnStateChangeEx("Process item with RubberBand as new take",4,-1);
						Undo_EndBlock(__LOCALIZE("Process item with RubberBand","sws_undo"),0);
					}
				}
			}
		}
	}
}