Click here to Skip to main content
14,738,360 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: okay. I ... really like TypeScript Pin
honey the codewitch14-Sep-19 2:53
mvahoney the codewitch14-Sep-19 2:53 
GeneralRe: okay. I ... really like TypeScript Pin
Sander Rossel14-Sep-19 3:00
professionalSander Rossel14-Sep-19 3:00 
GeneralRe: okay. I ... really like TypeScript Pin
honey the codewitch14-Sep-19 3:06
mvahoney the codewitch14-Sep-19 3:06 
GeneralRe: okay. I ... really like TypeScript Pin
Sander Rossel14-Sep-19 3:22
professionalSander Rossel14-Sep-19 3:22 
GeneralRe: okay. I ... really like TypeScript Pin
honey the codewitch14-Sep-19 3:28
mvahoney the codewitch14-Sep-19 3:28 
GeneralRe: okay. I ... really like TypeScript Pin
Sander Rossel14-Sep-19 6:08
professionalSander Rossel14-Sep-19 6:08 
GeneralRe: okay. I ... really like TypeScript Pin
honey the codewitch14-Sep-19 6:10
mvahoney the codewitch14-Sep-19 6:10 
GeneralDo you still have the ugliest function you've ever written? Pin
honey the codewitch13-Sep-19 9:20
mvahoney the codewitch13-Sep-19 9:20 
here's the main render loop for Prang Replay, my midi looper for FL Studio

void _stdcall Replay::Gen_Render(PWAV32FS DestBuffer, int &Length) {
	// this takes almost no CPU, despite how it looks
	// there are almost no cases where all this code will run on the same call.
	unsigned long long p = looper.pos;
	int bts = looper.beats;
	float bps = looper.tempo / 60;
	float spb = looper.sampleRate / bps;
	unsigned long long i = 0;
	midi_message midi;
	vector<Loop>& loops = looper.loops;
	// rotate the loops left or right, if requested
	if (1 < loops.size() && looper.rol != looper.ror) {	
		if(looper.rol) {
			loops.push_back(*loops.begin());
			loops.erase(loops.begin());
			if (-1 < looper.lastPushIndex) {
				--looper.lastPushIndex;
				if (0 > looper.lastPushIndex)
					looper.lastPushIndex += looper.loops.size();
			}
			looper.rol = false;
		}
		if(looper.ror) {
			loops.insert(loops.begin(), (*(loops.end() - 1)));
			loops.pop_back();
			if (-1 < looper.lastPushIndex) {
				++looper.lastPushIndex;
				if ((int)looper.loops.size() <= looper.lastPushIndex)
					looper.lastPushIndex -= looper.loops.size();
			}
			looper.ror = false;
		}
	}
	else
		looper.rol = looper.ror = false;

	// push the current loop, if requested.
	if(looper.push) {
		if (0xFFFFFFFFFFFFFFFF!=looper.tapPos) { // find our beats for bts
			unsigned long long len = p - looper.tapPos;
			i = (unsigned long long)ceil(len / spb);
			i = ((unsigned long long)ceil(i / bts))*bts; // quantize to Beats
			bts = (int)i;
			if (0 == bts)
				bts = looper.beats;

		}
		if (bts)
		{
			unsigned long long bp = p;
			vector<midi_event>::iterator it = looper.events.end() - 1;
			vector<midi_event>::iterator cur = it;
			unsigned long long bl = (unsigned long long)(spb*bts);
			unsigned long long bs = bp - bl;
			if (looper.events.size()) {
				while ((*it).pos > bs) {
					--it;
					if (looper.events.begin() == it)
						break;
				}
				while (looper.events.end() != it && it->pos < bs)
					++it;
			}
			Loop loop;
			loop.eventIndex = 0;
			loop.length = bl;
			loop.pos = 0;
			if (looper.events.size()) {
				while (it <= cur) {
					midi_event ev(*it);
					ev.pos -= bs;
					loop.events.push_back(ev);
					++it;
				}
			}
			loops.push_back(loop);
			looper.hanging = looper.keyContext; // store the last keys state
			looper.lastPushIndex = loops.size() - 1;
		}
		looper.push = 0;
		looper.tapPos = 0xFFFFFFFFFFFFFFFF;
		pEditor->ParamsToControls();
	}
	// iterate over the current loops, playing them.
	vector<Loop>::iterator it = loops.begin();
	while (it != loops.end()) {
		// play the next events from this loop
		Loop& loop = (*it);
		int lec = loop.events.size();
		if (lec) {
			while (loop.eventIndex >= lec)
				loop.eventIndex -= lec;
			unsigned long long n = Length + loop.pos;
			int nc = 0;
			while (true) {
				unsigned long long lp = loop.events[loop.eventIndex].pos;
				if (lp < loop.pos)
					lp += loop.pos;
				if(lp<n) {
					midi = loop.events[loop.eventIndex].midi;
					loop.noteCounter.process_message(midi);
					looper.noteCounter.process_message(midi);
					midi = looper.noteCounter.filter_message(midi);
					if (looper.enabled && midi.status)
						PlugHost->MIDIOut_Delayed(HostTag, (int)midi);
				}
				else break;
				++loop.eventIndex;
				if (loop.eventIndex >= lec)
					loop.eventIndex -= lec;
				 ++nc; if (nc == lec) break;
				
			}
			loop.pos += Length;
			if (loop.pos > loop.length)
				loop.pos -= loop.length;
		} else  
			it->pos+=Length;
		while (it->pos >= it->length)
			it->pos -= it->length;
		++it;
	}
	// play the unlooped main events
	while ((size_t)looper.eventIndex < looper.events.size()) {
		midi_event e(looper.events[looper.eventIndex]);
		if (Length <= e.pos - p)
			break;
		looper.noteCounter.process_message(e.midi);
		looper.incomingNoteCounter.process_message(e.midi);
		midi_message m = looper.noteCounter.filter_message(e.midi);
		if(looper.enabled && 0!=m.status)
			PlugHost->MIDIOut_Delayed(HostTag, (int)m);
		++looper.eventIndex;
	}
	// pop the current loop if requested, killing notes as needed.
	if(looper.pop) {
		if (loops.size()) {
			Loop* ploop = &(*loops.rbegin());
			for (int i = 0; i < 16; ++i) { // channels
				for (int j = 0; j < 128; ++j) { // notes
					looper.noteCounter.note[i][j]-=ploop->noteCounter.note[i][j];
					if (looper.noteCounter.note[i][j] <= 0 && ploop->noteCounter.note[i][j] > 0) {
						looper.noteCounter.note[i][j] = 0;
						midi_message m;
						m.extra = midiOut;
						m.status = 0x80 | i;
						m.data1 = j;
						m.data2 = 0;
						PlugHost->MIDIOut_Delayed(HostTag, (int)m); // send note off
					}
				}
			}
			loops.pop_back();
		}
		if (looper.loops.size() == looper.lastPushIndex)
			--looper.lastPushIndex;
		looper.pop = 0;
	}
	looper.pos += Length;
	Length = 0;
}

When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

JokeRe: Do you still have the ugliest function you've ever written? Pin
W Balboos, GHB13-Sep-19 9:54
mveW Balboos, GHB13-Sep-19 9:54 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
honey the codewitch13-Sep-19 9:55
mvahoney the codewitch13-Sep-19 9:55 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
MarkTJohnson13-Sep-19 10:09
professionalMarkTJohnson13-Sep-19 10:09 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
honey the codewitch13-Sep-19 10:10
mvahoney the codewitch13-Sep-19 10:10 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
David O'Neil13-Sep-19 10:12
professionalDavid O'Neil13-Sep-19 10:12 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
honey the codewitch13-Sep-19 10:14
mvahoney the codewitch13-Sep-19 10:14 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
Chris Maunder13-Sep-19 10:26
cofounderChris Maunder13-Sep-19 10:26 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
honey the codewitch13-Sep-19 10:27
mvahoney the codewitch13-Sep-19 10:27 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
Sander Rossel14-Sep-19 2:31
professionalSander Rossel14-Sep-19 2:31 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
honey the codewitch14-Sep-19 2:42
mvahoney the codewitch14-Sep-19 2:42 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
Sander Rossel14-Sep-19 3:01
professionalSander Rossel14-Sep-19 3:01 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
honey the codewitch14-Sep-19 3:10
mvahoney the codewitch14-Sep-19 3:10 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
Sander Rossel14-Sep-19 3:18
professionalSander Rossel14-Sep-19 3:18 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
honey the codewitch14-Sep-19 3:19
mvahoney the codewitch14-Sep-19 3:19 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
dandy7214-Sep-19 9:06
Memberdandy7214-Sep-19 9:06 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
Chris Maunder16-Sep-19 6:00
cofounderChris Maunder16-Sep-19 6:00 
GeneralRe: Do you still have the ugliest function you've ever written? Pin
Jörgen Andersson13-Sep-19 12:24
professionalJörgen Andersson13-Sep-19 12:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.