Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411423 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 18, 2024, 02:48:28 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsAudio Processing C#
Pages: [1]
Print
Author Topic: Audio Processing C#  (Read 6691 times)
louisdeb
Level 4
****



View Profile
« on: May 12, 2013, 12:23:09 PM »

Can anyone recommend some tutorials for real time audio processing in C#?
I wanna make a digital effects unit.
Logged
Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #1 on: May 12, 2013, 02:51:18 PM »

I could tell you a million things about how to do it in C++.  In any case the starting point is to get a callback-based audio output API and some tools for lock-free transmission of data between threads.

From what I hear, audio callbacks can be extremely dangerous to use in garbage-collected systems like C#, so it may be that this isn't possible.  Using queue-based systems (as may be necessary) will mean higher latency and possible glitches if the queue runs out, but otherwise you can synthesize as much as you like.
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
louisdeb
Level 4
****



View Profile
« Reply #2 on: May 12, 2013, 11:47:54 PM »

Hm, I'm much more familiar will C# than C++ (though that said, i'm still fairly new to C#)...
Could you recommend me some starting points for C++ (in terms of audio processing, I'll probably pick up the syntax along side). I don't really want to ask you to write a massive page on what I should do if it means I look at it and go... 'uh that looks way too tough' or something.

Thanks for the info though :D
Logged
eclectocrat
Level 5
*****


Most of your personality is unconscious.


View Profile
« Reply #3 on: May 14, 2013, 05:56:01 AM »

As someone who has worked in audio before... please pardon my cynicism and... uh.

First, are you sure you want to do this? Yes I am being patronizing, but bear with me...
While you can surely do some cool things by playing around, you are far better off just getting libraries that work, unless this is a skill that you'd like to get good at? If that is the case, then do as Evan suggested and jump ship to C++, almost all serious audio development is being done with C/C++.

Second, get ready to unlearn a lot of what you learned in general purpose programming. The rules of real-time contexts are very tough, you will discover that many of the techniques you are used to are not allowed.

Thirdly, have fun. Just don't think that you will whip out something that is performant and useful soon.

Ultimately I really enjoyed working with audio, but it is a lot of work, and you have to invest in the framework, and your own skills and experience. I have talked to more than one person who 'just wants to make a VST', and have quickly learned that they didn't care as much as they think they did Smiley

Please pardon the negativity, I still wake up from priority inversion nightmares...
Logged

I make Mysterious Castle, a Tactics-Roguelike
motorherp
Level 3
***



View Profile
« Reply #4 on: May 14, 2013, 06:10:06 AM »

JUCE is supposed to be pretty good for developing audio plugins.  Might be worth looking into.
Logged
louisdeb
Level 4
****



View Profile
« Reply #5 on: May 14, 2013, 06:20:49 AM »

@eclectocrat

I dont mind patronization :D my whole point for wanting to do this was for my computing A2 next year (we have to do a project). And I wanted to make something that could easily create presets and which people could then download onto a bit of hardware which I'd have an input and output and people could effectively share and create easily a load of different effects. I know it'd be a load of work and that's why what this thread is for is me to look into what it would involve and the length of it.

(we're taught pascal at school but my roots are in electronics and that's where my core understanding of signal processing comes from. my c# knowledge comes from unity but then some expansion into XNA).

I was thinking that maybe I could use Matlab to process the signal (in case anyone has experience with that) but that seems both expensive and not viable for a years work. This wasn't going to just be a VST but actually a full project (also wasn't planning on doing the hardware in the same year).

If you have some tutorials for C/C++ audio processing I'll read through those but am keeping in mind the advice on difficulty! (This is not me being set on doing this, hey, maybe I'll even have an excuse to make a video game for the project which would be awesome - though it needs to have a purpose for an end user / commissioner).

Anyway thanks :D
Logged
eclectocrat
Level 5
*****


Most of your personality is unconscious.


View Profile
« Reply #6 on: May 14, 2013, 07:23:33 AM »

Ok, glad to know you are serious, pardon my cynicism Smiley

I think matlab might be a good idea, because it will take care of many of the otherwise difficult platform details. If you want to get into more low level signal processing, you can take a look at STK. It is an audio framework developed academically since the mid 90's. It is not the best example of efficient realtime computing, but it has been in use for almost 20 years and most of the bugs have been worked out in that time.

In the technical forum on this board there was a pretty cleanly developed audio library mentioned recently, too lazy to research it over my 3G connection now Tongue.

I know this is blasphemy, but if you want to do some quick n' dirty experiments, webkitAudio for JavaScript is very usable, although I would cringe to try and make a full app with it, I hit a few walls when attempting any event sequencing. Still, if you just want to process signals it's certainly easy enough to use.

Good luck! I'll come back and post the thing that I can't remember right now but is nagging me in the back of my head...
Logged

I make Mysterious Castle, a Tactics-Roguelike
louisdeb
Level 4
****



View Profile
« Reply #7 on: May 14, 2013, 09:06:25 AM »

Sounds good to me.

What do you think about making the actual signal processing in matlab but then have an enclosing program in C#. (the interface and all, I think if I were able to get a community of effect developers that would be awesome).
Logged
Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #8 on: May 14, 2013, 09:30:19 AM »

The audio library he mentions is my project, and I'll be releasing an update very soon for reasons related to one of my contracts.  Check the link in my signature.

Documentation isn't very far along yet (check the sneak peek) but it's quite possible to develop your own extensions to the library as long as you follow the rules.  Use the existing effects (pitch, amp, synths) as templates.
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
louisdeb
Level 4
****



View Profile
« Reply #9 on: May 14, 2013, 10:13:46 AM »

Wow small world.

Will read into it.
Logged
Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #10 on: May 14, 2013, 12:28:27 PM »

Less a "small world" thing and more a "nobody in games is doing audio DSP" thing.  In the long run I'd like to try and change that.
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
eclectocrat
Level 5
*****


Most of your personality is unconscious.


View Profile
« Reply #11 on: May 14, 2013, 12:37:05 PM »

Less a "small world" thing and more a "nobody in games is doing audio DSP" thing.  In the long run I'd like to try and change that.

I might join you one day. I had been thinking of resurrecting my not-terrible dsp library, but I think that yours looks solid, does what I need, and more importantly, you seem to really care and put effort into it Smiley I have a fair bit of old Cocoa code for connecting graphs, and for displaying and editing waveforms in NSViews, if I can tear myself away from my game for a few minutes I might find a way to use it all somehow.
Logged

I make Mysterious Castle, a Tactics-Roguelike
louisdeb
Level 4
****



View Profile
« Reply #12 on: May 14, 2013, 01:38:33 PM »

Make a game out of it :D Can you try produce a wave input to obtain a wave output, or something. Though make it more fun than settings and all, make it people looking stupid by whining dumb things into the microphone.

I hope to get in to DSP. May start (this summer) in designing electronic circuits for it first. Or maybe a mix.
Logged
Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #13 on: May 14, 2013, 10:11:14 PM »

Haha, the update would actually make basic voice control pretty easy.  Split the microphone input up, bandpass out the different frequencies you want to detect, extract envelopes, and check the envelope values in the game thread each frame.  A weird idiom my system has is that when you want to analyze data, you play the stream doing the analysis at volume 0...

[/nerd]
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
louisdeb
Level 4
****



View Profile
« Reply #14 on: May 15, 2013, 02:33:06 AM »

aha i hope you have added that to some documentation because there will be some confused people out there o.O

what's the feasibility of displaying both frequency domain and time domain graphs in real time too ? and how difficult would that be to make?

edit: i figure you'd just look at each sample and then plot a graph of that, then update that graph every sample rate, and put the time stamp of the last sample back whatever your sample time is. (if that makes sense)
Logged
Evan Balster
Level 10
*****


I live in this head.


View Profile WWW
« Reply #15 on: May 18, 2013, 09:54:14 PM »

You'd want to display samplings of an envelope for time domain, and DFT samplings for frequency domain.

...and yeah, I need to finish the docs.  That's the only reason I haven't posted the new version yet.
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic