Hi, I was experimenting with the PluckedStringsDemo in the DemoRunner in the Projucer and I was wondering if there was any way to produce the same effect, but instead use a different sound file instead of the standard string pluck sound. If so, could someone please point me to any resources to learn how to do this? Thanks!
Hello Rohansuresh,
The âPluckedStringsDemoâ in JUCE is not using a sound file.
It is actually using some form of âphysical modellingâ.
That means: there is no sound file. Only an algorithm. More specifically: The Karplus-Strong algorithm. You can read more about the algorithm on Wikipedia:
In order to get a different sound, you have to change the algorithm.
As far as I understand, the Karplus-Strong algorithm is a simple form of digital waveguide synthesis. So you could also read up more on waveguides. Short introduction to digital waveguides by Julius O Smith:
https://ccrma.stanford.edu/~jos/swgt/
Hope that helps!
PS:
Maybe you are actually looking for a sampler demo? Then you have to open the âAudioSynthesiserDemoâ in the DemoRunner. In the AudioSynthesiserDemo you can click on âuse sampledâ sound. Then you get a sampler. And the sampler really is loading a sound file. Have a look at the line
std::unique_ptr<AudioFormatReader> audioReader (wavFormat.createReaderFor (createAssetInputStream ("cello.wav"), true));
There the file loading happens
Hi Alatar, thanks for your response it was very helpful. I tried using the AudioSynthesiserDemo but noticed that the app kept crashing every time I clicked the âUse Sampled Soundâ button. Do you know what might be causing this issue? Thanks!
And to follow up on my previous question, would it be possible to use the âBuild a MIDI synthesizerâ demo to create something like the AudioSynthesiserDemo, and how would I allow for different files to be input as the sampled sound instead of the sin wave generator? Thanks in advance!
It does not do that for me. You should debug the demo and check, where the crash is coming from.
Yes, that is possible.
You should be able to do it in the same way, as it is done in the âAudioSynthesiserDemoâ.
Cant tell you any details right away, because I would need to take a closer look at the tutorial first.
The SamplerSound and SamplerVoice classes inherit from SynthesiserSound and SynthesiserVoice, so the interface stays the same with a few additions, like the AudioFormatReader for the sampleâŠ
Thanks Alatar and daniel for your replies, Iâve definitely got a better understanding of how to make what Iâm trying to make now. I am having issues with this line however:
std::unique_ptr<AudioFormatReader>audioReader (wavFormat.createReaderFor (createAssetInputStream ("Sound1.wav"), true));
I keep getting this error: Use of undeclared identifier âcreateAssetInputStreamâ.
I tried changing the file path to a file that I have on my laptop but that didnât resolve the issue. Could this issue be linked to the fact that in the AudioSynthesiserDemo had these two include statements at the start of the code:
#include "../Assets/DemoUtilities.h"
#include "../Assets/AudioLiveScrollingDisplay.h"
but the code that Iâm writing does not? I tried keeping the include statements but the files could not be found and the code would only build when I removed the include statements (and the function with the above code). Do you have any advice on how to resolve this issue?
createAssetInputStream
seems to be a function. You must declare it somewhere. If it is not part of the JUCE class, which you are in.
If you are in Visual Studio, you can right-click on any function and select âGo To Definitionâ. If you do that in the demo, you can see, where it is declared.
Not sure how things work on XCode.
Indeed, it is a free function, that is included from here:
But you can replace it with any function, that returns a pointer to an InputStream, can be FileInputStream from disk, MemoryInputStream from BinaryData or from a zipfile using ZipFile::createStreamForEntry()
Thanks a lot for all the replies! I downloaded the DemoUtilities and included it in my program, and now everything is working.