electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
go to the radio page Live at electro-music.com radio 1 Please visit the chat
poster
 Forum index » Instruments and Equipment » WREN
HrastSVF 12dB/24dB
Post new topic   Reply to topic
Page 1 of 1 [17 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
hrastprogrammer



Joined: Oct 16, 2008
Posts: 260
Location: CPU
Audio files: 103

PostPosted: Wed Apr 16, 2014 2:30 am    Post subject: HrastSVF 12dB/24dB Reply with quote  Mark this post and the followings unread

Jan,

Attached is my combined 12dB/24dB State Variable Filter for WREN. Also, compared to the existing one, it can selfoscillate and has much better resonance characteristics, exponential filter cutoff modulation and a true drive/saturator built in.

Because SVF is 12dB by design, I used two serially connected 12dB modules (similar structure to the one in Tranzistow but non-ZDF version in this case, and very simplified). Each module has combined LP/BP/HP output (configurable through LP/BP/HP amounts) + there are individual LP/BP/HP/BR outputs from 12dB module.

Individual LP/BP/HP/BR outputs from 24dB module are not available because they don't have much sense in this design. I already developed a true 24dB SVF (Zero Delay Feedback version based on Linkwitz-Riley 24dB crossover structure) but it is not completely finished/tweaked yet and I am keeping it for Tranzistow or some of my future projects Wink

Note: HrastOsc module on FormStore is my design which is different from the one in your WREN source, so don't copy the whole unit but only HrastSVF, ImageHrastSVF and MemoHrastSVF components from the form (and redesign them according to your requirements).

Filter parameters:

Freq ... Cutoff frequency

Q ... Resonance

Input + Gain ... Filter input

Drive ... Input drive amount (0 = no drive, 1 = total clipping)

FM Input + Amount ... Cutoff frequency modulation input (exponential)

QM Input + Amount ... Resonance modulation input

LP ... LowPass filter amount

BP ... BandPass filter amount

HP ... HighPass filter amount

12dB ... Combined 12dB LowPass/BandPass/HighPass output level

24dB ... Combined 24dB LowPass/BandPass/HighPass output level

Outputs:

LP/BP/HP/BR ... Individual 12dB LowPass/BandPass/HighPass/Notch outputs

12dB ... Combined 12dB LowPass/BandPass/HighPass output

24dB ... Combined 24dB LowPass/BandPass/HighPass output

Notes:

Individual outputs are always available and they don't depend on LP/BP/HP amounts or 12dB/24dB levels.

To get notch on 12dB/24dB outputs set LP=1, BP=0 and HP=1.

For selfoscillation some signal must be present at input. For example, set input gain to 0.01 and send some noise to the input.

Be careful with very high resonance values (over 0.9) when using 24dB output.


HrastSVF.zip
 Description:

Download
 Filename:  HrastSVF.zip
 Filesize:  76.71 KB
 Downloaded:  538 Time(s)


_________________
https://www.hrastprogrammer.com/hrastwood/
https://hrastprogrammer.bandcamp.com/
Back to top
View user's profile Send private message Visit poster's website
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24075
Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320

PostPosted: Wed Apr 16, 2014 10:51 am    Post subject: Reply with quote  Mark this post and the followings unread

Shocked

I mean, that is great, and thank you!

I'm in the middle though of some big changes in how knobs work and all, some properties removed and renamed and different functions .. I'll try to get it in though .. it will need some hacking in the frm file to get it working Laughing

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
hrastprogrammer



Joined: Oct 16, 2008
Posts: 260
Location: CPU
Audio files: 103

PostPosted: Wed Apr 16, 2014 11:40 pm    Post subject: Reply with quote  Mark this post and the followings unread

I optimized the filter a little bit (removed two costly divisions) and added 2x oversampling, so it now behaves much better at very high frequencies ...


HrastUnit.zip
 Description:

Download
 Filename:  HrastUnit.zip
 Filesize:  2.4 KB
 Downloaded:  556 Time(s)


_________________
https://www.hrastprogrammer.com/hrastwood/
https://hrastprogrammer.bandcamp.com/
Back to top
View user's profile Send private message Visit poster's website
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24075
Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320

PostPosted: Fri Apr 18, 2014 7:30 am    Post subject: Reply with quote  Mark this post and the followings unread

Took a couple of hours .. but got it in ... no time to test it right now though, probably monday.
_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24075
Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320

PostPosted: Mon Apr 21, 2014 8:32 am    Post subject: Reply with quote  Mark this post and the followings unread

It works great!

Some more stuff to finish before I can release though.

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24075
Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320

PostPosted: Tue Apr 29, 2014 1:50 pm    Post subject: Reply with quote  Mark this post and the followings unread

It got released ... with quite a few other changes as well :-)

Updated the source package as well (beware, components changed quite a bit!).

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
hrastprogrammer



Joined: Oct 16, 2008
Posts: 260
Location: CPU
Audio files: 103

PostPosted: Wed Apr 30, 2014 4:33 am    Post subject: Reply with quote  Mark this post and the followings unread

Great!

Will compile it later ...

I see that you switched to lookup tables Wink

_________________
https://www.hrastprogrammer.com/hrastwood/
https://hrastprogrammer.bandcamp.com/
Back to top
View user's profile Send private message Visit poster's website
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24075
Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320

PostPosted: Wed Apr 30, 2014 10:38 am    Post subject: Reply with quote  Mark this post and the followings unread

Yes, had tables before BTW, and then concluded it was not any faster, now changed back to tables and it actually is faster ... it is a bit hard to get good timing as the processor seems to be be floating its speed.

Anyway. that's not the only change I made after seeing your code - thanks for the hints :-)

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
hrastprogrammer



Joined: Oct 16, 2008
Posts: 260
Location: CPU
Audio files: 103

PostPosted: Wed Apr 30, 2014 10:43 pm    Post subject: Reply with quote  Mark this post and the followings unread

I'm glad I could be of some help Very Happy

Yes, GetProcessTimes doesn't work well for audio processing - CPU usage will jump up and down just like in Task Manager.

I had this problem with my Tranzistow synthesizer and Hrastow VST host. In order to get consistent results you have to measure the time needed for each Tick and do an average over a larger interval.

Attached is my proposal for this ... Just search for BOHM/EOHM tags and modify it according to your needs.


FrmMain.pas
 Description:

Download
 Filename:  FrmMain.pas
 Filesize:  140.7 KB
 Downloaded:  637 Time(s)


_________________
https://www.hrastprogrammer.com/hrastwood/
https://hrastprogrammer.bandcamp.com/
Back to top
View user's profile Send private message Visit poster's website
hrastprogrammer



Joined: Oct 16, 2008
Posts: 260
Location: CPU
Audio files: 103

PostPosted: Thu May 01, 2014 5:32 am    Post subject: Reply with quote  Mark this post and the followings unread

I found a bug in the latest source ... Normal/Vintage button shouldn't be in KnobMap:

Code:

procedure THrastOsc.SetDefaults;
begin
  FInCache[HrastOsc_FMInput]:=0;
  FInCache[HrastOsc_PMInput]:=0;
  FInCache[HrastOsc_PWMInput]:=0;
  FKnobmap:=[
    HrastOsc_Freq,
    HrastOsc_Morph,
    HrastOsc_Shape,
    HrastOsc_Bandlimit,
    HrastOsc_PW,
    HrastOsc_PWM,
    HrastOsc_FM,
    HrastOsc_PM,
    HrastOsc_Vintage, // Should be removed!
    HrastOsc_Level
  ]
end;


Otherwise it couldn't be turned off because dezipper tries to dezip it and the appropriate FInCache value never drops to zero.

_________________
https://www.hrastprogrammer.com/hrastwood/
https://hrastprogrammer.bandcamp.com/
Back to top
View user's profile Send private message Visit poster's website
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24075
Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320

PostPosted: Thu May 01, 2014 10:22 am    Post subject: Reply with quote  Mark this post and the followings unread

Ok, overlooked that, thanks. Removed Vintage from the KnobMap for the necxt release.

Will look at your code too this evening.

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24075
Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320

PostPosted: Thu May 01, 2014 1:22 pm    Post subject: Reply with quote  Mark this post and the followings unread

Ok, I see what you mean re. CPU usage, but that does not address the problem I'm having ... your numbers will be a bit lower as they only show audio processing.

When you hit F10 in Wren a HTML page will be generated with clock counts for all the modules, cables and some other stuff. It should open in your default browser, but if not the file is in a data sub directory of the main Wren directory.

The numbers in that table will vary wildly .. in general they seem to get lower when the program gets more CPU demanding (i.e. for larger patches).. also they seem to get lower after some time (many minutes or hours even?) ... and this is what makes it hard to compare different implementations.

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
hrastprogrammer



Joined: Oct 16, 2008
Posts: 260
Location: CPU
Audio files: 103

PostPosted: Wed May 07, 2014 9:51 pm    Post subject: Reply with quote  Mark this post and the followings unread

Didn't have time to look into this before ...

I see what you're trying to achieve - to determine CPU usage for each module in the way it was done on Nord Modular. But, this is a very tricky job. On Motorola 56000 you could just look at instruction timings, count the cycles and that's it. On today's CPUs this is almost "mission impossible": multiple execution units, out-of-order execution, branch prediction, 3 levels of cache, etc., etc., not talking about Windows task switching and various background processes ... For example, the other day I managed to squeeze 1% of the CPU in Tranzistow just by rearranging some assembler code.

Blue Hell wrote:
The numbers in that table will vary wildly .. in general they seem to get lower when the program gets more CPU demanding (i.e. for larger patches).. also they seem to get lower after some time (many minutes or hours even?)


I looked at CpuUsage unit and I think this is because you are using GetTickCount and Now functions. Both of them have the resolution of 1ms at best, so those small errors are accumulating over time. Try QueryPerformanceFrequency & QueryPerformanceCounter to see if it gets any better ...

A few remarks related to CPU power saving (if you have already done that then just ignore them):

(1) Intel SpeedStep (EIST) should be disabled in BIOS => This one really doesn't work well for realtime audio processing. You can keep various C-states enabled, but turn EIST off.

(2) Windows power plan should be set to "Max. performance" with minimum and maximum processor state set to 100%.

(3) It is recommended to disable hyperthreading in BIOS.

_________________
https://www.hrastprogrammer.com/hrastwood/
https://hrastprogrammer.bandcamp.com/
Back to top
View user's profile Send private message Visit poster's website
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24075
Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320

PostPosted: Thu May 08, 2014 10:28 am    Post subject: Reply with quote  Mark this post and the followings unread

HrastProgrammer wrote:
I looked at CpuUsage unit and I think this is because you are using GetTickCount and Now functions.


Nope, you didn't look Wink

It does not use the Now function at all and it uses the GetTickCount function only to see if enough time passed to perform another usage query.

And apart from that those functions are not used for the profiling Laughing

Thanks for the recommendations tho .. might want to use that when I run out of time on a patch.

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
hrastprogrammer



Joined: Oct 16, 2008
Posts: 260
Location: CPU
Audio files: 103

PostPosted: Thu May 08, 2014 10:52 am    Post subject: Reply with quote  Mark this post and the followings unread

I looked (in a hurry, have to admit that) and saw this:

Code:
aCounter.LastUpdateTime := Now;


Didn't look above because I didn't expect that you'll give the variable a name of built-in function Wink

_________________
https://www.hrastprogrammer.com/hrastwood/
https://hrastprogrammer.bandcamp.com/
Back to top
View user's profile Send private message Visit poster's website
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24075
Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320

PostPosted: Thu May 08, 2014 1:35 pm    Post subject: Reply with quote  Mark this post and the followings unread

It's cool Hrast - I understand.

Meanwhile I read up a bit on the subject, it's indeed not easy Confused

Guess I will have to live with it more or less. Your recommendations should stabilize the readings, but taking time to let 'm settle seems to work reasonably good as well.

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
hrastprogrammer



Joined: Oct 16, 2008
Posts: 260
Location: CPU
Audio files: 103

PostPosted: Fri May 09, 2014 12:05 am    Post subject: Reply with quote  Mark this post and the followings unread

Yes, I read some yesterday, too:

http://www.strchr.com/performance_measurements_with_rdtsc

I would like to do some code profiling because I think there are still a few places where I could save a clock or two in Tranzistow.

Agner's performance monitoring package looks OK for what I intend to do:

http://www.agner.org/optimize/testp.zip

And in general - Agner's site is a great and very useful resource about CPU internals and code optimization:

http://www.agner.org/optimize/

_________________
https://www.hrastprogrammer.com/hrastwood/
https://hrastprogrammer.bandcamp.com/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic
Page 1 of 1 [17 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » Instruments and Equipment » WREN
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use