Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main:
- bl init
- b replay
- replay:
- mov r0,0 @initialize r0 to be played
- mov r4,0 @a reference register as the current peak
- ldr r6, =pitch @Loading the pitch location
- ldr r7, [r6, 4] @Loading the first element on the pitch
- mov r5, r7 @Use r5 as a reference from the first element
- ldr r8, [r6] @Size of the pitch
- mov r9, 1 @pitch Counter
- ldr r3,=duration @loads array location
- ldr r10, [r3,4] @loads first element of array
- mov r11, r10 @Duration Counter
- b top_wave
- top_wave: @Label that change r6 to positive peak
- ldr r4, =0x7fff @high signal
- mov r0, r4 @override r0 with r4
- sub r10, 1 @increment counter register by 1 each loop
- sub r7, 1 @Adding 1 to the counter
- cmp r10, 0
- beq switch_pitch
- 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
- beq bottom_wave @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 top_wave
- bottom_wave: @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
- sub r10, 1
- add r7, 1 @Substracting 1 to the counter
- cmp r10, 0
- beq switch_pitch
- cmp r7, r5
- beq top_wave
- bl BSP_AUDIO_OUT_Play_Sample
- b bottom_wave
- switch_pitch:
- add r9, 1
- cmp r8, r9
- beq replay
- mov r12, 4
- mul r12, r9, r12
- ldr r7, [r6,r12]
- mov r5,r7
- ldr r10, [r3,r12] @Duration for 0.125
- mov r11, r10 @Duration Counter
- b top_wave
- .data
- pitch:
- .word 38
- .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
- duration:
- .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