Adding Stereo output?

Request a new command, feature, or improvement

Moderator: MSandro

Post Reply
User avatar
Calloway
Posts: 100
Joined: Apr 30th, '18, 00:28
Location: Eastern United States

Adding Stereo output?

Post by Calloway » Sep 16th, '18, 21:25

Would it be possible to have stereo output in GP?
For example, the note block could extend to another input for left/right/center output and if none is detected default to center.

It's a small suggestion but it really can make a difference if people want to get creative with sounds.

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: Adding Stereo output?

Post by JohnM » Feb 9th, '19, 12:56

Stereo is actually supported by the underlying system. Here's some help I got from the GP command line:

Code: Select all

gp> help openAudio
Open the audio output driver. The optional frameCount argument is the number of stereo or mono samples (frames) to buffer, a power of 2 between 256 and 8192. Output is mono unless optional stereoFlag argument is true. Arguments: [frameCount stereoFlag]
gp> help writeSamples
Write sound samples (an array of signed, 16-bit integers). If stereo, left and right channels are interleaved. Arguments: sampleArray
I haven't tried it, but I think if you manually open the driver in stereo mode then you *might* be able to use the "play samples" block to output a stereo buffer. If that doesn't work, you can use "write samples" directly, passing a "BinaryData" object to it with the left and right samples interleaved.

In short, stereo is possible, although it will require you to "roll your own" stereo sound output loop.

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: Adding Stereo output?

Post by JohnM » Feb 9th, '19, 12:57

By the way, here are all the sounds "primitives".

Code: Select all

-- Sound --
   openAudio
   closeAudio
   samplesNeeded
   writeSamples
   fft
   generateNoteSamples
   sendMIDI
   startSpeech
   stopSpeech
   startAudioInput
   stopAudioInput
   readAudioInput
I got this list from the list of primitives you get from typing "help" at the GP command prompt.

User avatar
Calloway
Posts: 100
Joined: Apr 30th, '18, 00:28
Location: Eastern United States

Re: Adding Stereo output?

Post by Calloway » Feb 11th, '19, 01:36

Ah I see, so a psuedo-stereo solution would be possible.
I'll try working the kinks out somehow

What're the startSpeech and stopSpeech primitives used for?

Post Reply