Calling Chip Gracey's singing demo as an object
SingingDemoSCALES2.spinVocalTract.spinStereoSpatializer.spinHi all, I'm in the depths of confusion. I am going through the Propeller labs and studying sections 5 and 6 and still not getting something. It says in the labs, it's a common practice to copy and paste example Start and Stop methods into objects. The Singing demo doesn't have this in it, so I have been trying to read and apply what I think I figure out. The short of it is I want to call this object from another object and I want to only pass a single note to the singing object. I think that's pretty reasonable. However, I am not getting there. I have tried adding something like this to the singing program
And then try to call it from a simple main program using SingingDemoScales2.start
It doesn't happen and I have played about for hours with little progress.
I also will need to limit the number of cogs Chip's application uses, so I changed it to only make 2 calls to VocalTract and commented out everything that is basso and soprano. Do I have that correct? How can I check how many cogs are running total? I don't see a command or example, I just see that cognew returns zero if I am out of cogs.
And finally I am hoping to just basically pass one number of sixteen to Chip's singing demo and mod the dat table to play one note, so that has to be in my object call, I thought it would be something like, SingingDemoScales2.start(12)
Thanks for any pointers in the right direction.
Dave
VAR long stack[1000] 'Cog stack space byte cog 'Cog ID PUB Start : okay | i {{Start singing process in new cog; return True if successful store in okay. }} Stop okay := (cog := cognew(SingingDemoSCALES2(notetosing), @stack) + 1) PUB Stop ''Stop blinking process, if any. if cog cogstop(cog~ - 1)
And then try to call it from a simple main program using SingingDemoScales2.start
It doesn't happen and I have played about for hours with little progress.
I also will need to limit the number of cogs Chip's application uses, so I changed it to only make 2 calls to VocalTract and commented out everything that is basso and soprano. Do I have that correct? How can I check how many cogs are running total? I don't see a command or example, I just see that cognew returns zero if I am out of cogs.
And finally I am hoping to just basically pass one number of sixteen to Chip's singing demo and mod the dat table to play one note, so that has to be in my object call, I thought it would be something like, SingingDemoScales2.start(12)
Thanks for any pointers in the right direction.
Dave
Comments
Objects must launch their own cogs, and then can return the cog to the parent object.
So you need to put this code into chip graceys singing demo object.
Much how other objects are written with a start and stop PUB in the object, most objects have a "PUB start" to do the cog launching.
Either merge the singing demo with your code, or you need to modify the singing object so it launches its own cogs.
I'm still not getting that. The code I posted I did put into Chip Gracey's singing demo. The way I understand it is that, you call another object from your parent object, one of the first things that object should do is launch a new cog. The start routine does that and also checks if you already had a cog open for this object, if you did, it stops before you overwrite what you had going on in the stack, if you didn't already have it open, then the cogid is stored so when you are all done, you can stop the cog. Then normal program execution can go on in the called object completely in parallel to other processes.
I'm not getting why I can't put this code in Chip's object and then simply use dot notation to start and stop it from a parent application. I do need this to be running separately on it's own. My main program is calling a RFID reader to read tags, the tagid then determines which note I would have this object sing. All while starting and stopping a conveyor belt and monitoring a couple switches.
Thanks for the help, I'm really a bit over my head.
Ok, so after reading, re-reading and really getting more lost I have gotten to this point. This simplecall.spin, seems to do something. At least it seems to download to the propeller demo board. It even seems to wait a couple seconds before it emits a continous high pitched noise. I have added stack space and really played around without much success. I just need to call Chip's singing demo from another parent object and pass one changing parameter from the parent to the child. Where have I gone astray? I went through all the samples in the PEkit labs and I thought I followed them. It all seems so clear until I try to call this singing routine, which was written as a parent object in the demo. Is there a reason that a parent object like this can't be modified to become a child object to a new parent? Am I missing something that parent-child must have?
thanks,
Dave