Advertisement
Guest User

Untitled

a guest
May 2nd, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 2.05 KB | None | 0 0
  1. main:
  2.   bl init
  3.   b replay
  4.  
  5. replay:
  6.   mov r0,0        @initialize r0 to be played
  7.   mov r4,0        @a reference register as the current peak
  8.   ldr r6, =pitch  @Loading the pitch location
  9.   ldr r7, [r6, 4] @Loading the first element on the pitch
  10.   mov r5, r7      @Use r5 as a reference from the first element
  11.   ldr r8, [r6]    @Size of the pitch
  12.   mov r9, 1     @pitch Counter
  13.   ldr r3,=duration @loads array location
  14.   ldr r10, [r3,4] @loads first element of array
  15.   mov r11, r10    @Duration Counter
  16.  
  17.   b top_wave
  18.  
  19. top_wave:    @Label that change r6 to positive peak
  20.   ldr r4, =0x7fff @high signal
  21.   mov r0, r4      @override r0 with r4
  22.   sub r10, 1      @increment counter register by 1 each loop
  23.   sub r7, 1        @Adding 1 to the counter
  24.   cmp r10, 0
  25.   beq switch_pitch
  26.   cmp r7, 0      @Because the Period = 1/f and the BSP is 48khz then to get the period for 1/440HZ we multiply is by 48khz
  27.   beq bottom_wave @This will change the peak to negative peak if high peak has reach the half period
  28.   bl BSP_AUDIO_OUT_Play_Sample @This will play the sound at the particular value of r0
  29.  
  30. b top_wave  
  31.  
  32. bottom_wave:  @Label that change r6 to positive peak
  33.  ldr r4, =0x8000 @Setting the negative peak at 0x7fff
  34.  mov r0, r4      @Putting the negative peak value to r0 to be played
  35.  sub r10, 1
  36.  add r7, 1      @Substracting 1 to the counter
  37.  cmp r10, 0
  38.  beq switch_pitch
  39.  cmp r7, r5
  40.  beq top_wave
  41.  bl BSP_AUDIO_OUT_Play_Sample
  42.  
  43. b bottom_wave
  44.  
  45. switch_pitch:
  46.  add r9, 1
  47.  cmp r8, r9
  48.  beq replay
  49.  mov r12, 4
  50.  mul r12, r9, r12
  51.  ldr r7, [r6,r12]
  52.  mov r5,r7
  53.  ldr r10, [r3,r12] @Duration for 0.125
  54.  mov r11, r10    @Duration Counter
  55.  b top_wave
  56.  
  57. .data
  58. pitch:
  59.  .word 38
  60.  .word 218,0,218,0,218,0,218,0,183,0,183,0,183,0,183,163,146,0,146,0,146,0,146,0,130,0,146,0,163,0,183,0,194,0,218,0,245,218
  61.  
  62. duration:
  63.  .word 12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,12000,6000,6000,6000,6000,6000,6000,6000,6000,6000,6000,6000,6000,6000,12000,12000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement