Dark Bit Factory & Gravity

PROGRAMMING => Purebasic => Topic started by: energy on July 17, 2011

Title: 4Klang Software Synthesizer usage in Purebasic
Post 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...
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: Shockwave on July 20, 2011
Thanks for posting your wrapper :)
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: padman on July 20, 2011
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?
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: Raizor on July 20, 2011
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)
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: padman on July 20, 2011
lol, yep, that's truly amazing. K+  :D
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: energy on July 20, 2011
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!!
 
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: Raizor on July 21, 2011
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?
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: energy on July 21, 2011
I just tested it out.
i tried with demo of fruity Loops.



Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: Raizor on July 21, 2011
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?
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: energy on July 21, 2011
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.
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: niek on February 18, 2013
Thank you very much!! Will try it with version 5.10 of PB.
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: Watt–Wilton on October 02, 2013
Well I dont think that its no good to use 4klang with PB, incase
PB does not support crinkler.
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: energy on November 10, 2013
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
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: Dad1916 on November 23, 2013
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
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: Ampli on October 20, 2018
Sorry for posting in this old Thread, Is it possible somehow to convert this 4klang usage to PureBasic Linux?
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: Rbz on October 21, 2018
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:
Code: [Select]
ImportC "-lSDL2"
Here is a "C" code used to setup sdl audio, I think it should be easy to convert to purebasic:

Code: [Select]
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++;
}
}

Code: [Select]
/* 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:
Code: [Select]
synthBuffer = AllocateMemory(#MAX_SAMPLES*#SAMPLE_TYPE*2)
Title: Re: 4Klang Software Synthesizer usage in Purebasic
Post by: Ampli on October 21, 2018
Thanks alot, I will look into it and see if I can get it to work.