Short: Generate simple audio using Python. Author: wisecracker@tesco.net (Barry Walker) Uploader: wisecracker tesco net (Barry Walker) Type: dev/src Version: 0.00.30 Architecture: generic Distribution: Public Domain, Emailware. ============================================================================ Architectures: Classic AMIGAs, WinUAE and E-UAE. ------------------------------------------------ MINIMUM Requirements Are:- -------------------------- 68EC020 CPU and 2MB RAM total, example, a standard A1200(HD). WinUAE, AF2005 minimum, E-UAE. Standard OS3.0x install or better. Full Python 1.4.x, minimum, installed. (Python 1.5.2 to 2.0.x are also available on AMINET.) (Now Python 2.4.6 is available for advanced 68K machines.) ---------------------------------------------------------------------------- History. -------- 12-12-2011. Version 0.00.30:- Correct a very minor error in the Python code that will probably never, ever, be detected. 21-11-2011. Version 0.00.20:- Added keyboard access to alter output level and show how it is done. 14-11-2011. Version 0.00.10:- Original upload to AMINET... ---------------------------------------------------------------------------- To install just download the "Ami_Square_Wave.py.txt" file and rename it to "Ami_Square_Wave.py" without the quotes. Drag this file into the PYTHON: volume and away you go... From a Python prompt:- >>> execfile("PYTHON:Ami_Square_Wave.py") And away you go... ---------------------------------------------------------------------------- The DEMO assembly code that will be compiled and converted. Call the code beep.asm... From a CLI and using the a68k anf blink from AMINET:- Prompt> a68k beep.asm Some reports here... Prompt> blink beep.o Some reports here... This code is TOTALLY position independent. start: ;"beep.asm" test code... movem.l d0-d7/a0-a6,-(sp) ;Save all registers just in case. movea.l $4,a6 ;Set ~execbase~. moveq #16,d0 ;Length of square wave data. moveq #2,d1 ;Set to chip ram. jsr -198(a6) ;Allocate memory for the task. beq.s getout ;On error, Quit. move.l d0,a0 ;Set address in chip ram. move.l #$3f3f3f3f,(a0) ;Set first four bytes of sixteen. addq.l #4,a0 ;Move addres by four. move.l #$3f3f3f3f,(a0) ;Set next four bytes of sixteen. addq.l #4,a0 ;Move addres by four. move.l #$80808080,(a0) ;Set next four bytes of sixteen. addq.l #4,a0 ;Move addres by four. move.l #$80808080,(a0) ;Set last four bytes of sixteen. ;This ensures absolute position ;independence. lea $dff000,a5 ;Set HW register base. move.w #$000f,$96(a5) ;Disable audio DMA. move.l d0,$a0(a5) ;Set address of audio data. move.w #8,$a4(a5) ;Set length in words. move.w #64,$a8(a5) ;Set volume to maximun. move.w #220,$a6(a5) ;Set the period. move.w #$00ff,$9e(a5) ;Disable any modulation. move.w #$8201,$96(a5) ;Enable audio DMA. wait: btst #6,$bfe001 ;If LMB pressed then Quit. beq.s closeme ;Do it. bne.s wait ;Play the tone until LMB pressed... closeme: move.w #$000f,$96(a5) ;Disable audio DMA. move.l d0,a0 ;Address of the square wave data. moveq #16,d0 ;The data length to recover. jsr -210(a6) ;Free assigned memory. getout: movem.l (sp)+,d0-d7/a0-a6 ;Restore all registers. clr.l d0 ;Set returm code OK. rts nop even end ---------------------------------------------------------------------------- The text HEX file to be edited for the Python code:- Prompt> Type HEX beep > beep.hex Gives a text file "beep.hex" that has the contents:- 0000: 000003F3 00000000 00000001 00000000 ...ó............ 0010: 00000000 00000021 000003E9 00000021 .......!...é...! 0020: 48E7FFFE 2C780004 70107202 4EAEFF3A Hç.þ,x..p.r.N®.: 0030: 67682040 20BC3F3F 3F3F5888 20BC3F3F gZ @ Œ????X. Œ?? 0040: 3F3F5888 20BC8080 80805888 20BC8080 ??X. Œ....X. Œ.. 0050: 80804BF9 00DFF000 3B7C000F 00962B40 ..Kù.ßð.;|....+@ 0060: 00A03B7C 000800A4 3B7C0040 00A83B7C . ;|...€;|.@.š;| 0070: 00DC00A6 3B7C00FF 009E3B7C 82010096 .Ü.Š;|....;|.... 0080: 08390006 00BFE001 670266F4 3B7C000F .9...¿à.g.fô;|.. 0090: 00962040 70104EAE FF2E4CDF 7FFF4280 .. @p.N®..Lß..B. 00A0: 4E754E71 000003F2 NuNq...ò ---------------------------------------------------------------------------- With careful manipulation of the Python code you could have control of the audio levels, channels, frequency, etc, using this method... Enjoy finding simple solutions to often very difficult problems... ---------------------------------------------------------------------------- The archive is Public Domain/Emailware and you may modify it/them as you please for your OWN experiments. See below. I would dearly love an Email from you even if you think it is absolute rubbish... :) (Original idea and (C)2007 goes to B.Walker, G0LCU.) ---------------------------------------------------------------------------- IMPORTANT:- ----------- The Legal Stuff:- ----------------- These programs are Public Domain and no profit will be made from them, also all of the files must remain unaltered and intact including this one. The author is not responsible for any damage to, or loss of, or failure of equipment or data caused in any way by the use of these programs. There is NO warranty with the use of these software releases and YOU USE THEM AT YOUR OWN RISK. ---------------------------------------------------------------------------- Testing Evaluation:- -------------------- All WinUAE, E-UAE and Classic AMIGA test conditions were/are running standard OS3.0x/OS3.1x and using standard ~topaz 8~ fonts throughout. I have no idea what strange configuration setups will create so refer to the ~The Legal Stuff~ above. ---------------------------------------------------------------------------- Contact:- --------- Mr Barry Walker, G0LCU. Email:- wisecracker@tesco.net URL:- http://homepages.tesco.net/wisecracker/ Author of the ~TestGear?~ projects in the ~docs/hard~ drawer of AMINET. ---------------------------------------------------------------------------- A very useful HardWare related site, (C) Anthony Hoffman, for modifications, schematics, repairs and the like is:- http://amiga.serveftp.net/ ============================================================================