1024_ToneGenerator / Help needed

franz's picture

Hi, i don't want to seem like flooding the forum, however i'm in heavy need for some help/advice.

KnM developed the Audio file player, and i guess (afaik) Dust developed a AU sound generator. This clearly demonstrated that audio was possible in the QC environment.

So I'm myself trying to build a little Tone generator. Progress is good so far and everything is working.

However, when enabling sound output, i can hear a small crack - probably due to device initialization. This also happens when changing parameters of the buffer, or start/stop alternatively.

Do you fellow dev. have any experience on how to handle this situation ? I assume i'm not unique, and that you might also have gone through this problem. Any link or advice truly welcome. Thxx for your consideration/ Peace to the community

Plugin and example patch is attached - 10.5/10.6

PreviewAttachmentSize
_1024_ToneGenerator.zip18.43 KB

vade's picture
Re: 1024_ToneGenerator / Help needed

Well, without the source its hard to say, but clicks happen in DSP programming because you immediately jump from one value to another, and that discontinuity needs to be smoothed out. Any large jumps that happen within a single sample sized difference need to be smoothed over time.

This is very issue common when programming in audio patching environments like Max/MSP, PD, etc.

franz's picture
Re: 1024_ToneGenerator / Help needed

Here's the source, in case you wanna have a look at it. If so, i'll be more than grateful to you if you had the kindness to throw a glimpse at sending a float array directly to the audio buffer (commented in the source). This would simply allow to interpret images as sound - via fixed size buffer -

Also, i assume that adding a smooth patch in QC won't do, i'll have to smooth out the value manually in the plugin ... and there I'm clueless ...

PreviewAttachmentSize
_1024_TonePlayer source.zip19.1 KB

smokris's picture
Re: 1024_ToneGenerator / Help needed

When starting or stopping the oscillator, you could apply an amplitude envelope --- at start fade in the oscillator over 50-100ms, and at stop fade it out.

To smooth out frequency changes, you could maintain a "current oscillator position" variable to which you add a delta every time a sample is requested. I.e., the playback head will always move from its current position with a given velocity, instead of being computed absolutely.

franz's picture
Re: 1024_ToneGenerator / Help needed

[quote: When starting or stopping the oscillator, you could apply an amplitude envelope]

that's a good idea. A simple multiplication will do, i guess. Will try that right now.


EDIT : Well, it did the trick. Thanks smokris for the tip ! Here's a updated plugin, with better example comp.

Still looking on how to send float array to the buffer tho'

PreviewAttachmentSize
_1024_ToneGenerator.zip18.63 KB

cybero's picture
Re: 1024_ToneGenerator / Help needed

Well without seeing the source code I'm left wondering if you've been trying to do some thing programmatic to the audio latency?

Also when stopped and restarted, the sound is entirely lost.

Just noticed you'd posted the source after I started to respond & BTW the loss of audio is not a Core Audio service loss system wide, it's composition specific. Will look at the source later.

And the updated plugin and the advice about amplitude envelope.

gtoledo3's picture
Re: 1024_ToneGenerator / Help needed

This is REALLY cool. I also am experiencing the issue with starting and stopping the Viewer, and having the patch not start after the first time. The only thing that will solve that is closing and restarting QC. The patch itself can be enabled/disabled, and play can be turned true/false successfully on that first play.

Throwing this out there... you can already do flanging in QC by starting two audio feeds in asynch (or at a set offset). Why doesn't someone write that or a slapback delay, or a million other twists on that premise into a QC audio effect? It can already be done, but it would be cool to have it integrated and "massaged" a bit.

dust's picture
Re: 1024_ToneGenerator / Help needed

sweet i missed this last night while i was messing with frequency converter. glad to see some others doing audio things in qc. this real cool. so im late on this one but that clicking your talking about which i don't hear as i just got the new version is always fixed with some adsr or attack sustain and decay. making a sort of interpolated envelop on the attack will fix the click as smorkis mentioned. there is a good site that has lots of code that can help with this stuff its http://www.musicdsp.org/ they have lots of code snippets mostly in c which is easily integrated into obj-c 2.0 with or without some modification. the c++ is usually done with a .mm file and after having a look at your source its pretty cool to see that is all obj-c which is weird as i thought the audio unit was all carbon based but your file apparently compiles as .m and .mm.

i was hoping you where doing this with a custom component as i have been having a hard time loading a custom component into a qc plug-in. but this is a great example. gives me hope that i can start doing some more things audio wise in qc. i just started recently using dips4 to integrate qc into a max 4 live solution but still am wishing to do more in qc. so bravo my friend.

so i seem to have some of the same issues george does as the first play works but subsequent plays do not unless i quit and reopen but its cool to see two of them work at the same time. i haven't taken the audio buffer approach you did with my au as i was graphing the nodes to hal layer that deals with that which is where i think i was running into some issues but by graphing some au nodes it gives you the flexibility to add some of apples eq mixers and what not into the mix which could prove useful to expand on the tone generation concept.

im wondering why you limit the frequency to 200 which in my opinion is pretty low as 220 is a2 @ 440 tuning and a base frequency although the tome generator seems to be in much higher frequency. so cool stuff im going to mess with the source a bit and see if will blow up my speakers when i bump the frequency limit up. actually i blew my amp with a track i was making the other day i guess the electro bass line i made was a bit heavy.

dust's picture
Re: 1024_ToneGenerator / Help needed

im a bit daft sometime had to look up (afaik) but to set the record strait from my perspective as there was some debate over the name of the au plug-in i built. my au plug-in was not developed by me. well the plug-in wrapper for qc was developed by me primarily from the some apple developer code. but for the record the plug-in merely access apples built in dls synth that was originally made by roland corp. i have no affiliation with roland and my only affiliation with apple is the few people from my school and they few people on this forum that work for apple. any bank that you use with the plug-in in is obviously subjected to what ever licensing you got the bank from unless you create the banks your self. as in with your tone generator regardless of where the sample code came from i'm pretty sure you can claim a full copy-write © or well if you pieced together some apple dev examples or open source i think you can claim it as yours. from my perspective i honestly can not claim ownership to synth just the plug-in wrapper i guess. im new to developing so there seems to be some grey area with issues like this. but yeah as far as i know i developed the au plugs wrapper but can't take full credit as it was mostly example from apples midi-synth. don't know if that clears anything up or not but glad to see some people doing audio things in qc so far it seems to be 1024, kineme, vade and i that have made some audio generative things in the context of a qc plug-in. if i missed someone sorry. (your chance to claim qc audio credits here)

franz's picture
Re: 1024_ToneGenerator / Help needed

well, i'd love to give a try a components. Do you have a starting point or a source template ? Can you do polyphony with components ?

  • in fact i'm trying to merge the particle plug and this one, having each particle emit sound based on velocity .... maybe that's impossible, but i'll have to try.