Dark Bit Factory &  Gravity
		PROGRAMMING => Purebasic => Topic started by: energy on July 17, 2011
		
			
			- 
				Here is the Purebasic wrap for 4klang.
http://4klang.untergrund.net/
I dont think that its no good to use 4klang with PB, incase 
PB does not support crinkler...
But have fun... 
			 
			
			- 
				Thanks for posting your wrapper :)
			
 
			
			- 
				Yup, this looks interesting. Thanks for posting. The only downside is, that you gotta write your own songs. Or is there a site where one can download songs?
			
 
			
			- 
				
Yup, this looks interesting. Thanks for posting. The only downside is, that you gotta write your own songs. Or is there a site where one can download songs?
I had a look round for 4klang songs a while back and there don't really seem to be many around.
I did find this fantastic demo on youtube showing off 4klang though. It's so realistic! Cloth simulation, rigid-body physics and superb music syncing: http://www.youtube.com/watch?v=7qb4uiczfeE (http://www.youtube.com/watch?v=7qb4uiczfeE)
			 
			
			- 
				lol, yep, that's truly amazing. K+  :D
			
 
			
			- 
				yes yu have to compose for yurself. 4klang generates an obj. with the renderer and sound 
inbuilt. so there's no need of an external replay routine.
to compose i take fruity loops.
As yu see in attachment same song as above done in jwasm+crinkler 1.3
is about 1,8k with 49sec to play!!
 
			 
			
			- 
				
yes yu have to compose for yurself. 4klang generates an obj. with the renderer and sound 
inbuilt. so there's no need of an external replay routine.
to compose i take fruity loops.
As yu see in attachment same song as above done in jwasm+crinkler 1.3
is about 1,8k with 49sec to play!!
You can make 4KLang songs in Fruity Loops?
			 
			
			- 
				I just tested it out. 
i tried with demo of fruity Loops.
			 
			
			- 
				
I just tested it out. 
i tried with demo of fruity Loops.
Cool stuff energy, I will give that a try too. Is it easy to set up?
			 
			
			- 
				let s say so. its hard to do music with that appz.
But i tested some appz eg madtracker, buzz, which are free.
but for me fruityloop is the best and simplest to compose.
but im not the musician.
			 
			
			- 
				Thank you very much!! Will try it with version 5.10 of PB.
			
 
			
			- 
				Well I dont think that its no good to use 4klang with PB, incase
PB does not support crinkler.
			 
			
			- 
				
Thank you very much!! Will try it with version 5.10 of PB.
Works with 5.20 with changes of an "OR"-Statement.
#Replay = #WHDR_BEGINLOOP Or #WHDR_ENDLOOP 
to
#Replay = #WHDR_BEGINLOOP | #WHDR_ENDLOOP
			 
			
			- 
				google complaining 
The Website Ahead Contains Malware!
Google Chrome has blocked access to 4klang.untergrund.net for now.
Even if you have visited this website safely in the past, visiting it now is very likely to infect your Mac with malware.
Malware is malicious software that causes things like identity theft, financial loss, and permanent file deletion. Learn more
			 
			
			- 
				Sorry for posting in this old Thread, Is it possible somehow to convert this 4klang usage to PureBasic Linux?
			
 
			
			- 
				Hi Ampli,
Unfortunately I don't have purebasic nor linux installed, but here some ideas for you to research about it.
Using Energy's example, you will need to remove "wimm.lib" and "kernel32.lib" they are windows specific, on linux you will use SDL.
Use something like this:
ImportC "-lSDL2"
Here is a "C" code used to setup sdl audio, I think it should be easy to convert to purebasic:
static void synthCallback(void *udata, Uint8 *stream, int len) {
	/* the music is stereo - use 32 bit for left and right channel */
	static int32_t* sample = (int32_t*)synthBuffer;
	int32_t* ptr = (int32_t*) stream;
	udata += 0;
	int i;
	for (i = len / (SYNTH_OUTPUT_SAMPLE_SIZE * SYNTH_CHANNELS); i > 0 ; i--) {
		/* loop the track */
		if (samplePosition >= MAX_SAMPLES) {
			samplePosition = 0;
			sample = udata;
		}
		/* copy left and right channel at the same time */
		*ptr++ = *sample++;
		samplePosition++;
	}
}
	/* audio specification */
	SDL_AudioSpec audioSpec;
	audioSpec.freq = SAMPLE_RATE;
	audioSpec.format = AUDIO_S16SYS;
	audioSpec.channels = SYNTH_CHANNELS;
	audioSpec.silence = 0;
	audioSpec.samples = SYNTH_PLAY_BUFFER;
	audioSpec.size = 0;
	audioSpec.callback = synthCallback;
	audioSpec.userdata = synthBuffer;
	/* setup audio */
	if (SDL_OpenAudio(&audioSpec, NULL)) {
		fprintf(stderr, "SDL_OpenAudio() failed\n");
		SDL_Quit();
		return EXIT_FAILURE;
	}
	/* no multicore - precalculate the music */
	__4klang_render(synthBuffer);
	/* start the music */
	SDL_PauseAudio(0);
Another thing to check is how to allocate memory for "synthBuffer", I believe it should be:
synthBuffer = AllocateMemory(#MAX_SAMPLES*#SAMPLE_TYPE*2)
			 
			
			- 
				Thanks alot, I will look into it and see if I can get it to work.