Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/CommonTypeDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

enum SythesiserAlgorithm {
NoiseCrawler,
SineChordCrawler
SineChordCrawler,
Reverb
};

enum CrawlingDirection {
Expand Down
6 changes: 4 additions & 2 deletions Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ImageSonificationProcessorEditor : public juce::AudioProcessorEditor

juce::ToggleButton noiseToggle;
juce::ToggleButton toggleEECS;
juce::ToggleButton reverbToggle;

juce::ToggleButton Crawl1Toggle;
juce::ToggleButton Crawl2Toggle;
Expand All @@ -59,9 +60,10 @@ class ImageSonificationProcessorEditor : public juce::AudioProcessorEditor
{ "random", Random, &Crawl3Toggle}
};

ToggleButtonInfo<enum SythesiserAlgorithm> buttons[2] = {
ToggleButtonInfo<enum SythesiserAlgorithm> buttons[3] = {
{ "Image as noise", NoiseCrawler, &noiseToggle},
{ "EECS 351 WN22", SineChordCrawler, &toggleEECS}
{ "EECS 351 WN22", SineChordCrawler, &toggleEECS},
{ "Reverb Effect", Reverb, &reverbToggle}
};

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImageSonificationProcessorEditor)
Expand Down
96 changes: 90 additions & 6 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ void ImageSonificationProcessor::changeProgramName(int index, const juce::String
void ImageSonificationProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
{
this->eecs351wn22Alg.prepareToPlay(sampleRate, samplesPerBlock);
this->sampleRate = sampleRate;



//---------------->




}

void ImageSonificationProcessor::releaseResources()
Expand Down Expand Up @@ -182,14 +191,26 @@ void ImageSonificationProcessor::processBlock(juce::AudioBuffer<float>& buffer,
this->eecs351wn22Alg.generate_next_samples(mono_signal, sample_len);
}

// rewrite mono signal into all (both) channels
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
auto* channelData = buffer.getWritePointer(channel);
for (int i = 0; i < sample_len; ++i) {
channelData[i] = mono_signal[i];
}
if (*algorithmParam == static_cast<float>(Reverb)) {


reverb.processStereo(buffer.getWritePointer(0), buffer.getWritePointer(1), buffer.getNumSamples());

}
if (*algorithmParam != static_cast<float>(Reverb))
{
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
auto* channelData = buffer.getWritePointer(channel);
for (int i = 0; i < sample_len; ++i) {
channelData[i] = mono_signal[i];
}

}
}
// rewrite mono signal into all (both) channels



}

//==============================================================================
Expand Down Expand Up @@ -227,6 +248,69 @@ void ImageSonificationProcessor::resetBitmap()

this->imageAsNoiseAlg.imageBitmapPtr = this->imageBitmapPtr;
this->eecs351wn22Alg.imageBitmapPtr = this->imageBitmapPtr;

auto image_height = imageBitmapPtr->height;
auto image_width = imageBitmapPtr->width;

int tabSize = image_height * image_width;

//int* tabR = new int[tabSize];
//int* tabG = new int[tabSize];
//int* tabB = new int[tabSize];

auto sumR = 0.0;
auto meanR = 0.0;
auto sumG = 0.0;
auto meanG = 0.0;
auto sumB = 0.0;
auto meanB = 0.0;

for (int i = 0; i < image_height; ++i)
{
for (int j = 0; j < image_width; ++j)
{
auto pix_c = imageBitmapPtr->getPixelColour(j, i);
short unsigned int r = pix_c.getRed();
short unsigned int g = pix_c.getGreen();
short unsigned int b = pix_c.getBlue();

//tabR[image_width*i+j] = r;
//tabG[image_width * i + j] = g;
//tabB[image_width * i + j] = b;
sumR += r;
sumG += g;
sumB += b;
}
}

//for (int i = 0; i < tabSize; ++i) {
// sumR += tabR[i];
//}

//for (int i = 0; i < tabSize; ++i) {
// sumG += tabG[i];
//}

//for (int i = 0; i < tabSize; ++i) {
// sumB += tabB[i];
//}

meanR = sumR / tabSize;
meanG = sumG / tabSize;
meanB = sumB / tabSize;

juce::Reverb::Parameters reverbParams;
reverbParams.roomSize = meanR/256; // Adjust room size (0.0f - 1.0f)
reverbParams.damping = 0.1f; // Adjust damping (0.0f - 1.0f)
reverbParams.wetLevel = meanG/256; // Adjust wet level (0.0f - 1.0f)
reverbParams.dryLevel = meanB / 256; // Adjust dry level (0.0f - 1.0f)
reverbParams.width = 1.0f; // Adjust stereo width (0.0f - 1.0f)
reverbParams.freezeMode = false; // Enable/disable freeze mode

reverb.setParameters(reverbParams);
reverb.setSampleRate(this->sampleRate);


}

//==============================================================================
Expand Down
4 changes: 4 additions & 0 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class ImageSonificationProcessor : public juce::AudioProcessor
#endif
{
public:

juce::Reverb reverb;

//==============================================================================
ImageSonificationProcessor();
~ImageSonificationProcessor() override;
Expand Down Expand Up @@ -82,6 +85,7 @@ class ImageSonificationProcessor : public juce::AudioProcessor
ImageAsNoiseAlgorithm imageAsNoiseAlg;
EECS351WN22algorithm eecs351wn22Alg;

double sampleRate = 0.0;

//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ImageSonificationProcessor)
Expand Down