Skip to content

Instantly share code, notes, and snippets.

@adubspea
Created August 19, 2015 17:06
Show Gist options
  • Save adubspea/3c6b95d795be154703bc to your computer and use it in GitHub Desktop.
Save adubspea/3c6b95d795be154703bc to your computer and use it in GitHub Desktop.
Northern Wind Sound 3
import arb.soundcipher.*;
SoundCipher sc = new SoundCipher(this);
for (int n = 7 ; n < 50; n += 7) { // N = average North wind direction
if (n < 5) {
sc.playNote(80, 60, 50);
} else if (n < 2) {
float[] pitches = {100, 64, 67, 71};
sc.playChord(pitches, 80, 4);
} else if (n > 2) {
sc.repeat(3);
sc.playNote (70, 40, 10);
float[] pitches = {50, 50, 50, 50};
sc.playChord(pitches, 80, 4);
}
}
@adubspea
Copy link
Author

How do I get one program to run a variety of sound? If many of the if statements are true how can I get it to play them all?

@psugihara
Copy link

Cool! I’ll take a look later today and see if I can figure it out.

@adubspea
Copy link
Author

Here's another example:

import arb.soundcipher.*;
SoundCipher sc = new SoundCipher(this);

for (int n = 7 ; n < 50; n += 7) { // N = average North wind direction for August 1 - 16
if (n >= 7){
float[] pitches = {50};
float [] dynamics = {50};
float[] durations = {15};
sc.playPhrase(pitches, dynamics, durations);

} else if (n > 0) {
sc.repeat(3);
sc.playNote (70, 40, 10);
float[] pitches = {50, 50, 50, 50};
sc.playChord(pitches, 80, 4);

}
}

@galenwp
Copy link

galenwp commented Aug 19, 2015

I'd have to be more familiar with SoundCipher. In general though: your statement doesn't have to be else if, it can just be if this then that many times over. Example:

a = 1
b = 2

if a is 1
  print 'a is 1'
if b is 2
  print 'b is 2'

That's pseudocode, but it should print

a is 1
b is 2

Know what I mean?

@adubspea
Copy link
Author

Nope, I don't know what you mean!
Can you give me another example?

@adubspea
Copy link
Author

for (int n = 7 ; n < 50; n += 7)

} if (s < 20) { //trying to get the program to play multiple notes by using if instead of if & else
float[] pitches = {60, 20, 30, 25};
float [] dynamics = {60, 60, 60, 60};
float[] durations = {5, 5, 5, 5};
sc.playPhrase(pitches, dynamics, durations);

if (n > 2){
float[] pitches = {50, 40, 30, 25};
float [] dynamics = {80, 80, 80, 80};
float[] durations = {5, 5, 5, 5};
sc.playPhrase(pitches, dynamics, durations);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment