home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / mus / Maestix / demos / AnalyzeInput.s < prev    next >
Text File  |  1995-02-25  |  5KB  |  170 lines

  1. *****************************************************************
  2. *                                *
  3. *    maestix.library-Demo:    AnalyzeInput            *
  4. *                                *
  5. *****************************************************************
  6. *
  7. *    Programmed by        Richard Körber
  8. *    Date            1995-01-30
  9. *
  10. *****************************************************************
  11. *  This demonstration shows the basic functions of the maestix    *
  12. *  library. It allocates the Maestro soundcard, select the de-    *
  13. *  fault input and shows wether there is a signal,  and if so,    *
  14. *  it analyzes the rate, source and emphasis bits.              *
  15. *****************************************************************
  16.  
  17.         INCDIR    "include:"
  18.         INCLUDE    exec.i            ; Library call macros
  19.         INCLUDE    dos.i
  20.         INCLUDE    maestix.i
  21.         INCLUDE    libraries/maestix.i    ;Reference includes
  22.  
  23.         SECTION text,CODE
  24.  
  25. *---------------------------------------------------------------*
  26. *    == START OF PROGRAM ==                    *
  27. *                                *
  28. start    ;-- Open all libraries -----------------;
  29.         lea    maestname(PC),a1    ;maestix
  30.         moveq    #35,d0            ; V35+
  31.         exec    OpenLibrary        ; open
  32.         move.l    d0,maestbase        ; store base
  33.         beq    error1            ; not found!
  34.         lea    dosname(PC),a1        ;dos for output
  35.         moveq    #0,d0            ; all versions
  36.         exec    OpenLibrary        ; open
  37.         move.l    d0,dosbase        ; store base
  38.         beq    error2            ; not found!
  39.     ;-- Open STDOUT ------------------------;
  40.         dos    Output            ;get STDOUT
  41.         move.l    d0,stdout
  42.         beq    error3
  43.     ;-- Allocate Maestro -------------------;
  44.         sub.l    a0,a0            ;no tags
  45.         maest    AllocMaestro
  46.         move.l    d0,maestro        ;^Maestro base
  47.         beq    error3
  48.         lea    msg_allocated(PC),a0
  49.         bsr    print
  50.     ;-- Set Modus --------------------------;
  51.         move.l    maestro(PC),a0        ;^Maestro base
  52.         lea    modustags(PC),a1    ;^Modus tags
  53.         maest    SetMaestro        ;set it now
  54.         lea    msg_modusset(PC),a0
  55.         bsr    print
  56.     ;-- Read Status ------------------------;
  57.         move.l    maestro(PC),a0        ;^Maestro base
  58.         moveq    #MSTAT_Signal,d0    ;signal on input?
  59.         maest    GetStatus        ;get the card status
  60.         tst.l    d0
  61.         bne.b    .foundsig
  62.         lea    msg_nosignal(PC),a0    ;no there is no signal
  63.         bsr    print
  64.         bra    exit            ;leave
  65.     ;-- Read Input Status ------------------;
  66. .foundsig    lea    msg_sigfound(PC),a0    ;signal found
  67.         bsr    print
  68.         move.l    maestro(PC),a0        ;^Maestro base
  69.         moveq    #MSTAT_Emphasis,d0
  70.         maest    GetStatus        ;get the input status
  71.         tst.l    d0
  72.         bne.b    .emphused
  73.         lea    msg_no(PC),a0        ;no emphasis used
  74.         bsr    print
  75. .emphused    lea    msg_emphasis(PC),a0
  76.         bsr    print
  77.         move.l    maestro(PC),a0
  78.         moveq    #MSTAT_CopyProh,d0
  79.         maest    GetStatus
  80.         tst.l    d0
  81.         bne.b    .prohibit
  82.         lea    msg_no(PC),a0        ;not prohibited
  83.         bsr    print
  84. .prohibit    lea    msg_prohibit(PC),a0
  85.         bsr    print
  86.         move.l    maestro(PC),a0
  87.         moveq    #MSTAT_DATsrc,d0
  88.         maest    GetStatus
  89.         tst.l    d0
  90.         bne.b    .datsrc
  91.         lea    msg_no(PC),a0        ;no dat source
  92.         bsr    print
  93. .datsrc        lea    msg_datsource(PC),a0
  94.         bsr    print
  95.         move.l    maestro(PC),a0
  96.         moveq    #MSTAT_Rate,d0
  97.         maest    GetStatus
  98.         cmp.l    #44100,d0
  99.         bne.b    .not441
  100.         lea    msg_44100hz(PC),a0    ; yep: show it
  101.         bsr    print
  102.         bra    exit            ; and exit
  103. .not441        cmp.l    #48000,d0        ;48 kHz or 32 kHz?
  104.         bne.b    .is32
  105.         lea    msg_48000hz(PC),a0    ; is 48kHz
  106.         bsr    print
  107.         bra    exit
  108. .is32        lea    msg_32000hz(PC),a0    ; is 32kHz
  109.         bsr    print
  110.     ;-- Exit program -----------------------;
  111. exit        move.l    maestro(PC),a0        ;Free Maestro
  112.         maest    FreeMaestro
  113.         lea    msg_freed(PC),a0
  114.         bsr    print
  115. error3        move.l    dosbase(PC),a1        ;close dos library
  116.         exec    CloseLibrary
  117. error2        move.l    maestbase(PC),a1    ;close maestix library
  118.         exec    CloseLibrary
  119. error1        moveq    #0,d0            ;Reply 0
  120.         rts                ;back to CLI
  121.     ;-- Tags -------------------------------;
  122. modustags    dc.l    MTAG_Input,INPUT_STD    ;use standard input
  123.         dc.l    MTAG_Output,OUTPUT_BYPASS
  124.         dc.l    TAG_DONE
  125.  
  126. *-------------------------------------------------------*
  127. *  print    Print some text to STDOUT        *
  128. *    -» A0.l    ^string, 0-terminated            *
  129. *                            *
  130. print        movem.l    d0-d3/a0-a3,-(sp)
  131.         move.l    stdout(PC),d1        ;prepare output
  132.         move.l    a0,d2
  133.         moveq    #-1,d3            ;get string length
  134. .scanend    addq.l    #1,d3
  135.         tst.b    (a0)+
  136.         bne.b    .scanend
  137.         dos    Write            ;print to Stdout
  138.         movem.l    (sp)+,d0-d3/a0-a3
  139.         rts
  140.  
  141. *---------------------------------------------------------------*
  142. *    == DATA SECTION ==                    *
  143. *                                *
  144. maestbase    dc.l    0            ;^Maestix Lib Base
  145. dosbase        dc.l    0            ;^Dos Lib Base
  146. stdout        dc.l    0            ;^Output FH
  147. maestro        dc.l    0            ;^Maestro Base
  148.  
  149. msg_allocated    dc.b    "** allocated maestro",$a,0
  150. msg_modusset    dc.b    "** set modus",$a,$a,0
  151. msg_nosignal    dc.b    "No signal on standard input",$a,0
  152. msg_sigfound    dc.b    "Signal found on standard input",$a,$a,0
  153. msg_no        dc.b    "no ",0
  154. msg_emphasis    dc.b    "emphasis",$a,0
  155. msg_prohibit    dc.b    "copy prohibition",$a,0
  156. msg_datsource    dc.b    "DAT source",$a,0
  157. msg_44100hz    dc.b    "rate: 44100 Hz",$a,0
  158. msg_48000hz    dc.b    "rate: 48000 Hz",$a,0
  159. msg_32000hz    dc.b    "rate: 32000 Hz",$a,0
  160. msg_freed    dc.b    $a,"** freed maestro",$a,0
  161.  
  162. maestname    dc.b    "maestix.library",0    ;Maestix name
  163. dosname        dc.b    "dos.library",0        ;Dos name
  164.         even
  165.  
  166. *---------------------------------------------------------------*
  167. *    == END ==                        *
  168. *                                *
  169.         END
  170.