Help with multicog use
Oldbitcollector (Jeff)
Posts: 8,091
Ok, I need some help wrapping my one track brain around an eight track Propeller.
I'm continuing to work on Rayman's 8bit wav code, attempting to get multiple wav files to play at the same time
to generate chords. I can't seem to get more than three notes played after each other.
I've even tried to separate the "player" code from the main program. no dice.
My main code looks something like this:
play2 is simply another attempt by creating more than one copy of the player code.
I've tried cognew without success. I want it to start the first play. and quickly jump to the
next while it is playing. What am I misunderstanding?
Thanks
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
Post Edited (Oldbitcollector) : 12/10/2008 11:37:12 PM GMT
I'm continuing to work on Rayman's 8bit wav code, attempting to get multiple wav files to play at the same time
to generate chords. I can't seem to get more than three notes played after each other.
I've even tried to separate the "player" code from the main program. no dice.
My main code looks something like this:
play.Player(@Wav,17000) 'C play2.Player(@Wav,15000) 'D play.Player(@Wav,13400) 'E
play2 is simply another attempt by creating more than one copy of the player code.
I've tried cognew without success. I want it to start the first play. and quickly jump to the
next while it is playing. What am I misunderstanding?
Thanks
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
Post Edited (Oldbitcollector) : 12/10/2008 11:37:12 PM GMT
Comments
Here's the main program
.play and .play2 are identical.
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
Post Edited (Oldbitcollector) : 12/10/2008 11:48:53 PM GMT
To have them play in parallel you would have to have to do what graphics does; send the instruction, the graphics cog receives it, clears par, which allows the spin cog to continue while the graphics does the drawing. Graphics cannot execute a new command until finished. You would have to use multiple cogs running wav playing code.
Depending on what you want to do, it may be better to try a synthesizer approach rather than stacking wavs.
Post Edited (Jetfire) : 12/10/2008 11:54:38 PM GMT
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
One simple way is to read a single sample from each track and add the samples together. The one problem with this is that it is possible for the sum to overflow the output bit width.
One way around that is to clip the sum to a maximum value. Another way is to output the average of the samples (division by a constant reduces volume). There is a whole field of research around mixing sound with minimal perceived distortion.
I've not played with sound on a Propeller yet, so I don't know what if any mixing support there already is.
if you don't want to change the assembly-code you have to call the Pub Player from different cogs to get it parallel playing
this means:
you have to start 2-7 cogs by cognew each running a loop that is waiting for a command that sets up the parameters pWav and speed
setting up the paremeters pWav and speed does NOT start a call of PUB player
AFTER all paremeters have been setup for EVERY cog
you set a global variable "play" true
EACH cog is waiting for this global variable "play" to get true
and THEN each cog can start do the call for the PUB Player
you can imagine the paremeter setup like the countdown for a olympic sprint of the athlets
each athlet hears the "get into startblock - ready - GO!" from the "starter" person
"get into startblock - ready" sets up pwav and speed
all athlets still HAVE TO wait until the "GO!"
the "GO!" arrives at each athlet at the same time and then each athlet get's out of the startblock using his OWN body (own cog) running down to the target-line
best regards
Stefan