Help understanding the demo


I’ve dug through the Audio demo trying to pick out what I need for a simple note sound system.

I’m trying to make a program that will turn a note on/off every second. I’m just trying to make a basic demo and will extend that later.

I’ve got my main class extending Timer to do this. My problem is audio, I just can’t get output. I’ve looked over the source code a bunch of times and it’s really hard to pick out what I need and what I don’t.

Anyways here’s my .h file:

[code]#ifndef MIDIPLAYER_H

#include “…/…/juce.h”
#include “SynthAudioSource.cpp”

class MIDIPlayer : public JUCEApplication,
public Timer

void initialise(const String&);
void shutdown();
const String getApplicationName();

void timerCallback();

long myTime;
bool isOff;

//AudioDeviceManager myAudioDeviceManager;

MidiMessageCollector myMidiMessageCollector;

AudioSourcePlayer myAudioSourcePlayer;
MixerAudioSource myMixerSource;
SynthAudioSource *mySynthSource;



I suppose I should mention that I have included a few of the classes from the demo in separate .cpp files. I slightly modified SynthAudioSource to accept my own MidiMessageCollector which I pass notes to. They’re all working in there ok, but I’m not sure what I’m missing for output. Here’s my cpp file:

#include “MIDIPlayer.h”

std::cout << “0\n”;
myTime = 0;
mySynthSource = new SynthAudioSource(&myMidiMessageCollector);

delete mySynthSource;

void MIDIPlayer::initialise(const String& commandLine){
std::cout << “Starting Up” << std::endl;

myMixerSource.addInputSource(mySynthSource, false);

AudioDeviceManager myAudioDeviceManager;

myAudioDeviceManager.initialise (1, /* number of input channels */
				 2, /* number of output channels */
				 0, /* no XML settings.. */
				 true  /* select default device on failure */);
myAudioDeviceManager.setAudioCallback (&myAudioSourcePlayer);




void MIDIPlayer::shutdown(){
std::cout << “Shutting Down” << std::endl;

const String MIDIPlayer::getApplicationName(){
return T(“MIDI Player”);

void MIDIPlayer::timerCallback(){
MidiMessage m(1, 2, 3);
if (isOff){
isOff = false;
float one = 1.;
m = MidiMessage::noteOn(1, 60, one);
} else {
isOff = true;
m = MidiMessage::noteOff(1, 60);
std::cout << "myTime: " << myTime << “\n”;


Any help getting output / explaining what’s wrong would be much appreciated.


It looks ok - what I’d do would be to put some breakpoints in the synth’s audio callback and see if it’s getting called at all, and if so, try to figure out why it’s not making any sound. I’m sure it’ll just be something simple that’s wrong.