![]() Play the audio for 5 seconds without creating a file: ffplay -f lavfi -i "sine=frequency=1000:duration=5" -autoexit -nodisp The file will be 2x as large, and ffprobe will say it has 2 channels instead of 1 channel. Stereo instead with -ac 2: ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -ac 2 out.wav Continue to modify Example 2 to generate a music song.Create a 5 seconds mono 1000Hz sinusoidal out.wav sound file: sudo apt-get install ffmpegįfmpeg -f lavfi -i "sine=frequency=1000:duration=5" out.wav Table 13.1 Time delay Programming Music Frequency Decimal value Note (Hz) loaded into counter 2 (port address 0x42) Hexadecimal number loaded into counter 2 (port address 0x42) D 1FB4 5 seconds Example 1 A 152F 8 seconds your code A 0A97 10 seconds your code 4. Follow the same procedure using Table 13.1. The formula for the value 8116 is 1.1931 MHz:147Hz. The value 8116 will be loaded into counter 2 (port address 42H). For example, the frequency for note D3 is 147 Hz. Modify Example 2 to generate the music tones of D3, A3, and A4. portAddress Counter): outh higherByte, portAddressCounter): printf("Design a mask with a logical operation to extract the lower byte from a 2-byte value in? print Design a mask with a logical operation to extract the higher byte from a 2-byte value'n") es printf("Your code'n": Turn on the speaker joperm(portAddress Speaker, 1, 1) Obtain the original setting of PORT B at 1/0 port address 61H portBbits - inb(portAddress Speaker) printf "The original setup of PORTB at port address (圆) is 0x%X\n", portBbits) Design a mask 0x03 to set the PBO and PB1 bits of PORTB at port address 0圆1 enableBits - portBbits 0x3: Iset PBO and PBI both as logic 1 printf("After the OR operation, the bits sent to port address 0圆1 are: 0x%X'n", enableBits) Send the variable enableBits to port address 0圆1 to turn on the speaker outb(enableBits, portAddress Speaker): sleep (5), //Send back the default setup of PORTB to port address 0圆1 outb(portBbits, portAddress Speaker): Close all ports ioperm(portAddressCounter, 2, 0) ioperm(portAddress Speaker, 1, 0) printf("Program is finished in ") return 0 ang nang-virtualbox:-/Desktop/MyDocs gcc toneGeneratorTemp.c wangwang-virtualBox:-/Desktop/MyDocs sudo a out The preset value is 1964 Design a nask with a logical operation to extract the lower byte from a 2 byte value Pestan a mask with a logical operation to extract the higher byte from a 2 byte value The original setup of PORTB at port 0xb1 ts ex31 After DR operation, the bits sent to port address 6圆1 are: 8x33 Program ts finished wanguwang-virtualBox:-/Desktop/MyDocs Figure 13.2 The output from toneGeneratorTemp.cģ. Your codeįor example, the preset value of D3 note is 1.1931817 MHz/147 HZ-8116 = 1F34 lowerByte =0xB4 higherByte - OxIF: outblowerByte. Design a mask with a logical operation to extract the higher byte from a 2-byte value. "Calculate the preset value in hexadecimal format and load it to counter 2 to generate a frequency presetvalue-clockFreq/generated Freq: printf "The preset value is %x \n", presetvalue) ******* ******** Design a mask with a logical operation to extract the lower byte from a 2-byte value. Write function of the outb(dataByteSent, portAddress) /********* ***** #include sys/lo.be #include #include #include unistd.h> int main() int clock Freq=(1.1931817 *1.0E6% / 1.1931817 MHz int generated Freq-147 1/147H int presetvalue unsigned char lowerByte, higherByte: unsigned char portBbits unsigned char enableBits: unsigned char control Word: unsigned short portAddressCounter, portAddress Control, portAddress Speaker, portAddress Counter=0x42, portAddress Control-0x43, portAddress Speaker-O圆l control Word=OxB6 Open the VO port addresses Ox42 and Ox43 to be accessed ioperm(portAddressCounter, 2, 1) //Send control information B6 to control register located at an I/O port address 0x43 outh(control Word, Ox43). ![]() Read function of the dataByteReceived inb(portAddress) H. Design a mask to set the B1 and PBO bits by a logical OR operation Ox03 G. Extract the higher byte from a 2-byte hexadecimal value E. Extract the lower byte from a 2-byte hexadecimal value D. Find a hexadecimal value in two bytes from the formula of clock Freq/generated Freq C. ![]() Example 13.2 tone Generator Temp.c File name: toneGienerator Temp.c Method: program on Linux A. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |