+ Reply to Thread
Results 1 to 12 of 12

Thread: Understanding vocal tract frame handler code

  1. #1

    Default Understanding vocal tract frame handler code

    Hi all,

    I've been going through the vocaltract code and trying to understand the frame handler routine (included below). I'm a bit of a newbie with the propeller machine code but I'm starting to get most of it now.

    I understand that the jmpret statements are used to split processing cycles between the vocal tract loop and the frame handler loop (as per the jmpret manual entry - I hope I'm right about this). However, I'm having difficulty understanding the reference to the cycles in the comments next to the instructions. Do they refer to the number of cycles that are used before the next vocal tract loop is executed? Why are there two values with or/ in between? And how are the number of cycles calculated? I thought each statement used 4 cycles for each statement?

    If anyone can offer any guidance, I would appreciate it very much.

    Thanks,

    Stephen

    Code:
     
    :ret                    long    :wait                   'pointer to next frame handler routine
     
    :wait                   jmpret  :ret,#loop              '(6 or 17.5 cycles)
                            mov     frame_ptr,par           'check for next frame
                            add     frame_ptr,#8*4          'point past miscellaneous data
                            add     frame_ptr,frame_index   'point to start of frame
                            rdlong  step_size,frame_ptr     'get stepsize
                            and     step_size,h00FFFFFF  wz 'isolate stepsize and check if not 0
            if_nz           jmp     #:next                  'if not 0, next frame ready
     
                            mov     :final1,:finali         'no frame ready, ready to finalize parameters
                            mov     frame_cnt,#13           'iterate aa..ff
    :final                  jmpret  :ret,#loop              '(13.5 or 4 cycles)
    :final1                 mov     par_curr,par_next       'current parameter = next parameter
                            add     :final1,d0s0            'update pointers
                            djnz    frame_cnt,#:final       'another parameter?
     
                            jmp     #:wait                  'check for next frame
     
    :next                   add     step_size,#1            'next frame ready, insure accurate accumulation
                            mov     step_acc,step_size      'initialize step accumulator                    
     
                            movs    :set1,#par_next         'ready to get parameters and steps for aa..ff
                            movd    :set2,#par_curr   
                            movd    :set3,#par_next
                            movd    :set4,#par_step
                            add     frame_ptr,#3            'point to first parameter
                            mov     frame_cnt,#13           'iterate aa..ff
    :set                    jmpret  :ret,#loop              '(19.5 or 46.5 cycles)
                            rdbyte  t1,frame_ptr            'get new parameter
                            shl     t1,#24                  'msb justify
    :set1                   mov     t2,par_next             'get next parameter
    :set2                   mov     par_curr,t2             'current parameter = next parameter
    :set3                   mov     par_next,t1             'next parameter = new parameter
                            sub     t1,t2           wc      'get next-current delta with sign in c            
                            negc    t1,t1                   'make delta absolute (by c, not msb)
                            rcl     vscl,#1         wz, nr  'save sign into nz (vscl unaffected)
                            mov     t2,#8                   'multiply delta by step size
    :mult                   shl     t1,#1           wc
            if_c            add     t1,step_size
                            djnz    t2,#:mult
    :set4                   negnz    par_step,t1            'set signed step
                            add     :set1,#1                'update pointers for next parameter+step
                            add     :set2,d0
                            add     :set3,d0
                            add     :set4,d0
                            add     frame_ptr,#1
                            djnz    frame_cnt,#:set         'another parameter?
     
     
    :stepframe              jmpret  :ret,#loop              '(47.5 or 8 cycles)
                            mov     :step1,:stepi           'ready to step parameters
                            mov     frame_cnt,#13           'iterate aa..ff
     
    :step                   jmpret  :ret,#loop              '(3 or 4 cycles)
    :step1                  add     par_curr,par_step       'step parameter
                            add     :step1,d0s0             'update pointers for next parameter+step
                            djnz    frame_cnt,#:step        'another parameter?
     
                            add     step_acc,step_size      'accumulate frame steps
                            test    step_acc,h01000000  wc  'check for frame steps done
            if_nc           jmp     #:stepframe             'another frame step?
     
                            sub     frame_ptr,#frame_bytes  'zero stepsize in frame to signal frame done
                            wrlong  vscl,frame_ptr
                            add     frame_index,#frame_bytes'point to next frame
                            and     frame_index,#frame_buffer_bytes - 1
     
                            jmp     #:wait                  'check for next frame
     
    :finali                 mov     par_curr,par_next       'instruction used to finalize parameters                 
    :stepi                  add     par_curr,par_step       'instruction used to step parameters

  2. #2

    Default Re: Understanding vocal tract frame handler code

    Do you think the cycles that are mentioned in the comments are referring to the number of multiple of 4-cycles that could take place? I don't really understand how they are calculated.

  3. #3

    Default Re: Understanding vocal tract frame handler code

    The "jmpret" instruction itself takes 4 cycles so the other number looks like it may be the calculated average execution time of the routine. I could not find any PASM instruction that takes x.5 cycles, which reinforces my conclusion.

  4. #4

    Default Re: Understanding vocal tract frame handler code

    I don't really understand one of the last statements though is the 3 or 4 cycles here.. that's only time to do 1 or less than 1 instruction? It doesn't sound right to me?

    Code:
    :stepframe              jmpret  :ret,#loop              '(47.5 or 8 cycles)
                            mov     :step1,:stepi           'ready to step parameters
                            mov     frame_cnt,#13           'iterate aa..ff
    
    :step                   jmpret  :ret,#loop              '(3 or 4 cycles)
    :step1                  add     par_curr,par_step       'step parameter
                            add     :step1,d0s0             'update pointers for next parameter+step
                            djnz    frame_cnt,#:step        'another parameter?

  5. #5

    Default Re: Understanding vocal tract frame handler code

    Dang it! Still can't delete a post.

    -Phil

  6. #6

    Default Re: Understanding vocal tract frame handler code

    I think I may have been wandering down the garden path on this one. I thought it was refering to instruction cycles since most were 4 or greater (4 cycles for a jmpret). It may be the number of loops through a subroutine or something else entirely. Author, author....some help please.

  7. #7

    Default Re: Understanding vocal tract frame handler code

    What did you post Phil? Did you delete the post in the end?

  8. #8

    Default Re: Understanding vocal tract frame handler code

    I misread the program fragment that you posted, thought I had the answer, posted it, then realized I was mistaken -- an Emily Litella (nevermind!) moment which, because of the no-delete policy, forever becomes part of forum history.

    -Phil

  9. #9

    Default Re: Understanding vocal tract frame handler code

    Thanks for looking at it though
    Will it only be Chip who could answer the question definitively?

  10. #10

    Default Re: Understanding vocal tract frame handler code

    Quote Originally Posted by Eternal-student View Post
    Will it only be Chip who could answer the question definitively?
    Probably. That said, don't get stuck on what might just be an ambiguous comment. Get creative with your own ideas.

  11. #11

    Default Re: Understanding vocal tract frame handler code

    Yes, ok thanks. I'm still getting to grips with the code and I think the frame handler code is really useful. I would still be interested in knowing what the cycles refer to though. It's such a nice and carefully written piece of code I can't imagine the comments were written by mistake. Does Chip read the forums?

  12. #12

    Default Re: Understanding vocal tract frame handler code

    If anyone reads this post in the future and knows the answer to it, please feel free to respond, even if the post very old and it is a long time since it was first posted. I guess I'm over fixating on this but I'd really like to know what the answer is about the commented cycles, if indeed there is one.

    Yours perseveringly,

    Stephen

+ Reply to Thread

Similar Threads

  1. TLC5940 code understanding
    By DXC in forum Propeller 1 Multicore Microcontroller
    Replies: 14
    Last Post: 08-17-2010, 05:56 PM
  2. vocal tract
    By ciguli miguli in forum Propeller 1 Multicore Microcontroller
    Replies: 3
    Last Post: 08-31-2009, 09:13 PM
  3. not understanding this code
    By JR_301 in forum Learn
    Replies: 2
    Last Post: 07-10-2009, 03:05 PM
  4. Vocal Tract on Propeller?
    By Dan Taylor in forum Propeller 1 Multicore Microcontroller
    Replies: 5
    Last Post: 05-22-2009, 02:58 AM
  5. Vocal Tract #sine error
    By mctrivia in forum Propeller 1 Multicore Microcontroller
    Replies: 6
    Last Post: 01-12-2009, 02:49 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts