Extreme noob can't tell what's going on

Hello, I’ve never used C++ in my life and so almost all of the vocabulary and syntax is total gibberish to me. Is there a simple way to get the bit value of a sample as a single named variable and then set the sample to a different bit value? Like I said, no idea what I’m doing. Seems like this should be a way to do it, but I can’t tell if that’s a function I can use (VSCode doesn’t seem to think so), a function definition or something else, and I don’t know how many of the arguments are necessary or what any of the variables mean.

Ultimately, my goal is to make an effect that takes the bit value of a sample, plugs it into a mathematical function and outputs the result. Also, if there’s a way to do the whole thing in Python instead of C++, please tell me how.

I realize this seems like I’m just being a lazy ass, but when I had to use C# for design class, it made me so stressed I almost dropped out. Never want to deal with C languages again.

do you want to do it as an audio plugin?

You can do any of this in python if you’re not interested in it running real time in a DAW.

Open up a wave file in python with the wave functions:
https://docs.python.org/3/library/wave.html

Then it will return an audio buffer similar to what you’ve linked you.

Process the buffer how you’d like and you can save it back out to a wave or pass it into whatever mathematical functions you’re interested.

I was intending to do it as an audio plugin, but I’ll certainly try the separate Python thing as well. Thank you

Well, for the audio plugin you can use the Projucer to generate your plugin project, it will give you a templated space to do your processing.

I’ve actually made a free beginner JUCE course w/ Kadenze & Output which may be helpful for you:

Intro To Audio Plugin Development | Kadenze

Good luck & welcome to the forums!

1 Like

If you want to avoid C++ but do realtime stuff another option that comes to my mind could be using something Max/MSP and its gen language that allows you to perform sample based processing in realtime. It gives you most math operations you’ll need for basic DSP and is a lot simpler than C++ as you only write code for processing one sample, the rest is hidden from you. I used it a few years ago to prototype some distortion algorithms and it really gets you started quickly, but needless to say you won’t achieve a performance comparable to C++ this way. I’m not sure, but I think you can somehow create plugins with Max.

In future, another option might be SOUL, however it is currently in an early beta stage so not available to you if you want to get started developing real world plugins right now.

That being said, if you plan to release a real-world audio plugin that should be usable by others too, I’d strongly suggest you to take a few months and learn C++ from scratch before trying to understand the depths of the JUCE docs as the one you linked above, as this currently is the only way to get the job done in a professional manner.

What have you tried/done so far? The documentation link you posted is to a function I haven’t ever needed so far after using Juce for a few years now. How did you end up finding that function in the documentation and why do you think it would be useful?

Also, what is a “bit value”? You wouldn’t really typically work with audio samples as bits, since for example the common plugin formats work with 32 (or 64) bit floating point samples. Even when reading in existing audio files (which often have 16 or 24 bit integer PCM samples), you would typically work with the audio as floating point buffers.

I concluded that function would be useful because, as far as I can tell, it returns the bit value of the sample. When I say bit value it means the actual value of the sample, but it feels weird to just say “value” so I added the bit without thinking. I also didn’t realize they’re usually measured as floats - was thinking rather low-level.

If you are doing an audio plugin (based on AudioProcessor), your processing code would look something like this :

void MyPluginAudioProcessor::processBlock(AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
	auto rawbuffers = buffer.getArrayOfWritePointers();
	for (int i = 0; i < buffer.getNumSamples(); ++i)
	{
		for (int j = 0; j < buffer.getNumChannels(); ++j)
		{
			float sample = rawbuffers[j][i];
			// modify sample, here just doing a simple gain change
			sample = sample * 0.5;
			rawbuffers[j][i] = sample;
		}
	}
}

Of course there are various additional details involved, but that’s the general outline for how to modify the incoming real time audio. If you need to be processing existing audio files in some way, that is still more involved. But it isn’t really clear from your initial post what you are actually trying to do.

Perfect! thank you, this is exactly what I was hoping for.

Hi @rekkandevar, you’ve already been given great advice by the previous posters! Unsurprisingly because they have all been extremely helpful to me in the past too! :wink:

I’m going to give you my two cents, but in no way take this as any authoritative answer, I am no where on the level to where the other posters are, nonetheless…

  1. @Jake_Penn’s kadenze course will REALLY help you. - Go and put that on your to do list first! JUCE/programming/Audio Dev world is a big ocean, and it looks like you’re trying to swim when you don’t even know how to float (:wink:) yet. Once you get through Jake’s course, you’ll have a better understanding of what JUCE is, what your initial idea really means in DSP, and the skills you are going to need to develop before you can even approach your initial idea.
  1. @PluginPenguin suggested Max/MSP and that’s absolutely my second choice. In fact, I would lean towards Max’s uglier older brother, PureData These two enviroments are great for prototyping ideas and understanding DSP. There is a great site to help you along your way: http://pd-tutorial.com and once you have whipped up your idea in PureData, you could learn about Libpd Which can embed your PureData patches into anything, (VST plugin, android app, even into JUCE, etc.)

  2. If you’re gonna want to do this seriously, you’re just going to have to get good at C++ and that’s by itself is a quite a mountain. 1 quick tip: there is the old way of doing things in C++ and the new way (often called “modern C++” or C++11/14/17) skip all the old books, tutorials, lectures, youtube videos, anything about ‘C’ programming language. - You’ll be wasting your time, (like I did). Look for something that deals with modern C++ --> this “zero - hero” course by Kate Gregory will probably suit you perfectly : https://www.youtube.com/watch?v=Cj2zLkHfK0s&list=PLB_QFf1fzn9O_22Q-P4xNajxIlbY3aCQk

Good luck on your journey.

4 Likes