Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .syntax unified
- .global main
- .type main, %function
- main:
- bl init
- b restart
- restart:
- mov r0,0 @initialize r0 to be played
- mov r4,0 @a reference register as the current peak
- ldr r6, =array @Loading the array location
- ldr r7, [r6, 4] @Loading the first element on the array
- mov r5, r7 @Use r5 as a reference from the first element
- ldr r8, [r6] @Size of the array
- mov r9, 1 @Array Counter
- mov r10, 12000@Duration for 0.25
- mov r11, 0 @Duration Counter
- b positive_peak
- positive_peak: @Label that change r6 to positive peak
- ldr r4, =0x7fff @Setting the positive peak at 0x7fff
- mov r0, r4 @Putting the positive peak value to r0 to be played
- add r11, 1
- cmp r10, r11
- beq change_pitch
- sub r7, 1 @Adding 1 to the counter
- 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
- @which will reslted with 109.090909
- @But we need the point for half of a period because each peak is only half a period
- @which is 54.5 but since we can't use float in integer then we use 55
- beq negative_peak @This will change the peak to negative peak if high peak has reach the half period
- bl BSP_AUDIO_OUT_Play_Sample @This will play the sound at the particular value of r0
- b positive_peak
- negative_peak: @Label that change r6 to positive peak
- ldr r4, =0x8000 @Setting the negative peak at 0x7fff
- mov r0, r4 @Putting the negative peak value to r0 to be played
- add r11, 1
- cmp r10, r11
- beq change_pitch
- add r7, 1 @Substracting 1 to the counter
- cmp r7, r5
- @ bleq change
- @when the subs reach 0 then the negative peak has reach half of the period which is 55 then we change it to positive
- beq positive_peak
- bl BSP_AUDIO_OUT_Play_Sample
- b negative_peak
- change_pitch:
- add r9, 1
- cmp r8, r9
- beq restart
- mov r12, 4
- mul r3, r9, r12
- ldr r7, [r6,r3]
- mov r10, 12000@Duration for 0.25
- mov r11, 0 @Duration Counter
- b positive_peak
- .data
- array:
- .word 27
- .word 82, 0, 69, 0, 61, 61, 0, 82, 0, 69, 0, 58, 61, 61, 0, 0, 82, 0, 69, 0, 61, 61 , 0, 69, 0, 82, 0
- @ print(cal(293.66));
- @ print(cal(349.23));
- @ print(cal(392));
- @ print(cal(415.30));
- @ 81.72716747258734
- @ 68.72261833175844
- @ 61.22448979591836
- @ 57.78954972309174
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement