Go Back   DriverHeaven > Forums > Hardware and Related Topics > kX Project Audio Driver Support Forum > Effects and the DSP
Register Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old Jan 11, 2008, 09:17 AM   #1 (permalink)
stylus02
DriverHeaven Junior Member
 
Join Date: Jan 2008
Location: germany, sb0090
Posts: 95
stylus02 is on a distinguished road

log_dane, exp_dane in c++

hi all,

to save some registers and instructions, i'm interested in c++ implementation of the microcode.
how do the c++ functions "log_dane", "exp_dane" have to be used correctly?
i have done following:

...
case VOL3_ID:
// lin > log calculation from vfader value
set_dsp_register(VOL3_P, (dword)log_DANE(value, 2));
break;
...
create_vfader(level_3, VOL3_ID, "s", 0 , 0x7fffffff, 85, 10, 50, 100);
...
sprintf(c, "% .1f", v/10.);
// shows float 0..1
...

when i dump the compilied kxl in dane only 0x0 and 0x1 are written in dsp register "vol3". where i am wrong?

thank you

kx it!
stylus02 is offline   Reply With Quote
Old Jan 11, 2008, 09:33 AM   #2 (permalink)
Russ
DriverHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 3,875
Russ has a spectacular aura aboutRuss has a spectacular aura aboutRuss has a spectacular aura about

Try this:
set_dsp_register(VOL3_P, _dbl_to_dspword(log_DANE(value, 2)));

BTW: Signals entering the DSP are divided by 4 (and multiplied by 4 when leaving), so any level detection code, etc, should take that into account.

... and welcome to the forum

Last edited by Russ : Jan 11, 2008 at 10:01 AM.
Russ is offline   Reply With Quote
Old Jan 11, 2008, 10:27 AM   #3 (permalink)
stylus02
DriverHeaven Junior Member
 
Join Date: Jan 2008
Location: germany, sb0090
Posts: 95
stylus02 is on a distinguished road

thank you russ. the _dbl_to_dspword conversion seems to work. i will take a closer look later to what it does exactly.
yes, i have noticed that: signals, which come out of a plugin, have a quadruple amplitude.
stylus02 is offline   Reply With Quote
Old Jan 11, 2008, 10:46 AM   #4 (permalink)
Russ
DriverHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 3,875
Russ has a spectacular aura aboutRuss has a spectacular aura aboutRuss has a spectacular aura about

It basically just converts the value (which is a double) to the 2's compliment version (i.e. fractional value), rounded to the nearest integer (IIRC).

i.e.
value * 2^31 + 0.5 (truncated at decimal point)

Last edited by Russ : Jan 11, 2008 at 10:52 AM.
Russ is offline   Reply With Quote
Old Jan 11, 2008, 11:20 AM   #5 (permalink)
Russ
DriverHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 3,875
Russ has a spectacular aura aboutRuss has a spectacular aura aboutRuss has a spectacular aura about

Quote:
Originally Posted by stylus02 View Post
yes, i have noticed that: signals, which come out of a plugin, have a quadruple amplitude.
Yes, the peak plugins are designed so that regular users do not have to think about the div4/x4 stuff, and thus they show the level as it will be after leaving the DSP (so the value on the peak plugin will be 4 times the value shown in the plugin's register(s)). The controls for most plugins are like this as well (when applicable).
Russ is offline   Reply With Quote
Old Jan 11, 2008, 11:38 AM   #6 (permalink)
stylus02
DriverHeaven Junior Member
 
Join Date: Jan 2008
Location: germany, sb0090
Posts: 95
stylus02 is on a distinguished road

it can be handled, when it's known. to show signals on software oscilloscopes they have to scaled down to 25%.
stylus02 is offline   Reply With Quote
Old Jan 11, 2008, 11:52 AM   #7 (permalink)
Russ
DriverHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 3,875
Russ has a spectacular aura aboutRuss has a spectacular aura aboutRuss has a spectacular aura about

Quote:
Originally Posted by stylus02 View Post
it can be handled, when it's known. to show signals on software oscilloscopes they have to scaled down to 25%.
No, they should not have to be scaled down since the peak plugin shows what the level should be in the recording application (i.e. what it will be when it leaves the DSP)... unless of course another plugin changes the level before that point.

i.e.
original level -> Div4 (entering the DSP) -> x4 (exiting the DSP (to recording software or whatever)) = original level again

The only difference is that DSP plugins (in the middle) work with the div4 level (gives overhead room for plugin calculations, etc), but this should be pretty much transparent for regular users (i.e. you only need to know about it if you are creating plugins that use level detection, etc (or you are using a plugin that does not account for it)).

<edit>
Sorry if I confused you... I mainly mentioned it because I thought that you might be doing level detection (or similair), as Log/Exp can be used for that (i.e. to convert linear values to log scale (and vice-versa) for dB comparison, etc).
</edit>

Last edited by Russ : Jan 11, 2008 at 12:35 PM.
Russ is offline   Reply With Quote
Old Jan 11, 2008, 02:28 PM   #8 (permalink)
stylus02
DriverHeaven Junior Member
 
Join Date: Jan 2008
Location: germany, sb0090
Posts: 95
stylus02 is on a distinguished road

no you don't confuse me. only c++ is able to do this .

when i'm checking the signal with the software osciloscope "oscilight" i have to scale down the plugin output level from 100% to 25%. when i do not, the osci shows only the first quarter of the signal amplitude. it looks like "hard cutted" at -0.25..0.25. really don't know if the software has a problem with 32 bit input data or it is the phaenomenon you described. but it can be solved as described above.

i actually work on a synthesizer and i would like to optimize an adsr envelope and something else i've written in microcode.

kx it!

Last edited by stylus02 : Jan 11, 2008 at 02:48 PM.
stylus02 is offline   Reply With Quote
Old Jan 11, 2008, 04:02 PM   #9 (permalink)
stylus02
DriverHeaven Junior Member
 
Join Date: Jan 2008
Location: germany, sb0090
Posts: 95
stylus02 is on a distinguished road

have tested some linear > log, linear > exp conversions with following c++ code:

set_dsp_register(VOL3_P, _dbl_to_dspword(log_DANE(value, 6)));
set_dsp_register(VOL3_P, _dbl_to_dspword(exp_DANE(value, 6)));

there are 2 tests for every instruction, one linear rampup an one linear rampdown.

here the results of the plugin outs viewed on and oscilloscope :

http://freenet-homepage.de/stylish-s...ane_0_to_1.jpg
http://freenet-homepage.de/stylish-s...ane_1_to_0.jpg
http://freenet-homepage.de/stylish-s...ane_0_to_1.jpg
http://freenet-homepage.de/stylish-s...ane_1_to_0.jpg

as you can see there are dropouts with nearly 0 or 1 values.
there must be a problem in functions. i have seen that eYagos's dynamica uses a
similarly interpolating version of such function.

ok this is very high skill level. i'm not that c++ professional at the moment.

Last edited by stylus02 : Jan 11, 2008 at 04:20 PM.
stylus02 is offline   Reply With Quote
Old Jan 11, 2008, 04:19 PM   #10 (permalink)
Russ
DriverHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 3,875
Russ has a spectacular aura aboutRuss has a spectacular aura aboutRuss has a spectacular aura about

Make sure that you account for the x4...

i.e.

What are you ramping up/down?
- Make sure the signal's range (in the DSP) is 0 to 0.25. If this is an external signal, then it is done automatically for you, but if it is a signal that you are creating in the DSP then you need to scale it's range yourself.

Last edited by Russ : Jan 11, 2008 at 07:24 PM.
Russ is offline   Reply With Quote
Old Jan 11, 2008, 04:41 PM   #11 (permalink)
stylus02
DriverHeaven Junior Member
 
Join Date: Jan 2008
Location: germany, sb0090
Posts: 95
stylus02 is on a distinguished road

ramp or saw waves, as we musicans say, are simple linear rise up or fall down functions like this f(x)=(-)ax.
no i think the smaller range is also concerned of the problem.
the picture's names tell what i have done. i have moved the slider constantly up from 0..1 and down from 1..0. the conversion is the c++ method right out the kxl.
stylus02 is offline   Reply With Quote
Old Jan 11, 2008, 05:15 PM   #12 (permalink)
stylus02
DriverHeaven Junior Member
 
Join Date: Jan 2008
Location: germany, sb0090
Posts: 95
stylus02 is on a distinguished road

the log-, exp- curves are recognizably. but the dropouts's are absolutely not acceptable. if i would put such an envelope to a sound, it would scratch like an old record player. *g*
stylus02 is offline   Reply With Quote
Old Jan 11, 2008, 07:20 PM   #13 (permalink)
Russ
DriverHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 3,875
Russ has a spectacular aura aboutRuss has a spectacular aura aboutRuss has a spectacular aura about

I am sorry but I still am not completely sure what you are using these instructions for (why not just use a logarithmic slider to being with?). I only know that you are setting DSP registers to converted linear slider values. I do not know what else you are doing in your C++ code, nor how these values are being used in your microcode.

Also, if you are going to use a slider for musical purposes, you should probably interpolate between value changes (in your microcode) as the resolution of the slider is probably not good enough for smooth results (depending on what you are using it for).
Russ is offline   Reply With Quote
Old Jan 11, 2008, 10:01 PM   #14 (permalink)
Lex Nahumury
DriverHeaven Senior Member
 
Join Date: Jan 2003
Location: The Netherlands
Posts: 1,728
Lex Nahumury is on a distinguished road

Quote:
Originally Posted by stylus02 View Post
when i'm checking the signal with the software osciloscope "oscilight" i have to scale down the plugin output level from 100% to 25%. when i do not, the osci shows only the first quarter of the signal amplitude. it looks like "hard cutted" at -0.25..0.25. really don't know if the software has a problem with 32 bit input data or it is the phaenomenon you described. but it can be solved as described above.

i actually work on a synthesizer and i would like to optimize an adsr envelope ..
Control signals generated in DSP like ADSR envelope generators, LFOs etc. often go from 0 to 1.
That is why they are clipping at DSP output due to 4x and that's why you have to temporarly scale them down in order to observe them in software osciliscope.
Audio signals on the other hand, traveling through DSP should always be kept below 'virtual kX DSP 0dB point' else they will clipp at the DSP output too.
The digital oscilators used in your Synth is audio signal!
Their peak amplitude must not exceed 'virtual kX DSP 0dB point' else they will clip too.
So there is nothing 'strange' going on here.
Just the difference between control signals and audio signals used in DSP.

@Russ; My guess is we are looking at a Control signal ramping up/down between 0-1
and that the OP is experimenting trying to move ADSR from microcode to C++ (wich is very tricky) to save DSP resources.

/Lex.
Lex Nahumury is offline   Reply With Quote
Old Jan 11, 2008, 10:07 PM   #15 (permalink)
Russ
DriverHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 3,875
Russ has a spectacular aura aboutRuss has a spectacular aura aboutRuss has a spectacular aura about

Doh, I know what the problem is...

Your slider range is KX_FXPARAM_LEVEL which is integer values, and log_DANE expects a double (-1..1). Divide the slider value by 2^31.

i.e.
set_dsp_register(VOL3_P, _dbl_to_dspword(log_DANE(value / 2147483648.0, 2)));

Sorry, between your description of the problem, and your pictures, and everything else, I wasn't completely following what you were saying.

<edit>
Didn't see Lex's reply... Yes, I think you are right that it is the control signal (I had thought this originally, but the pictures threw me off with all the ups and downs, and I got confused (I did not realize that is what he meant by dropouts... and then I thought it was some odd signal that was being ramped)).

Last edited by Russ : Jan 15, 2008 at 06:31 PM. Reason: spelling :)
Russ is offline   Reply With Quote
Reply



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

 
Powered by: vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
Artwork by Allan 'Zardon' Campbell, vBulletin implementation by Craig '5320' Humphreys based on original artwork by Ratchet.

All times are GMT -5. The time now is 03:42 PM. Copyright ©2008 DriverHeaven.net