続き
LET HEADERSIZE = 16 !'LET SAMPLESIZE = SAMPLEBIT / 8 * CHANNEL !'LET DATARATE = SAMPLESIZE * SAMPLINGFREQ !'LET PCMSIZE = NUM * SAMPLESIZE !'LET WAVEFILESIZE = PCMSIZE + 36 INPUT PROMPT "SAVE FILENAME(.WAV)=":N$ IF POS(N$,".")=0 THEN LET N$=N$ & ".WAV" OPEN #2:NAME N$,ACCESS OUTPUT PRINT #2:"RIFF"; PRINT #2:MKL$(WAVEFILESIZE); PRINT #2:"WAVEfmt "; PRINT #2:MKL$(HEADERSIZE); PRINT #2:MKI$(WAVETYPE); PRINT #2:MKI$(CHANNEL); PRINT #2:MKL$(SAMPLINGFREQ); PRINT #2:MKL$(DATARATE); PRINT #2:MKI$(SAMPLESIZE); PRINT #2:MKI$(SAMPLEBIT); PRINT #2:"data"; PRINT #2:MKL$(PCMSIZE); FOR K=NUM TO 1 STEP -1 FOR I=1 TO CHANNEL !'LET DAT(I,K)=MIN(2^(SAMPLEBIT-1)-1,MAX(-2^(SAMPLEBIT-1),INT(DAT(I,K)))) IF SAMPLEBIT=8 THEN LET E$=CHR$(DAT(I,K)+128) IF SAMPLEBIT=16 THEN LET E$=MKI$(DAT(I,K)) !'IF SAMPLEBIT=24 THEN LET E$=MKM$(DAT(I,K)) !'IF SAMPLEBIT=32 THEN LET E$=MKL$(DAT(I,K)) PRINT #2:E$; NEXT I NEXT K CLOSE #2 END
EXTERNAL FUNCTION CVI(A$) OPTION CHARACTER BYTE DECLARE NUMERIC A LET A=ORD(A$(1:1))+ORD(A$(2:2))*256 IF A>32767 THEN LET A=A-65536 LET CVI=A END FUNCTION
EXTERNAL FUNCTION CVM(A$) OPTION CHARACTER BYTE DECLARE NUMERIC A LET A=ORD(A$(1:1))+ORD(A$(2:2))*256+ORD(A$(3:3))*256^2 IF A>2^23-1 THEN LET A=A-2^24 LET CVM=A END FUNCTION
EXTERNAL FUNCTION CVL(A$) OPTION CHARACTER BYTE DECLARE NUMERIC A LET A=ORD(A$(1:1))+ORD(A$(2:2))*256+ORD(A$(3:3))*256^2+ORD(A$(4:4))*256^3 IF A>=2^31-1 THEN LET A=A-2^32 LET CVL=A END FUNCTION
EXTERNAL FUNCTION MKI$(X) OPTION CHARACTER BYTE DECLARE STRING A$,B$ LET A=INT(X) IF A<0 THEN LET A=A+65536 LET A$=CHR$(MOD(A,256)) LET B$=CHR$(INT(A/256)) LET MKI$=A$ & B$ END FUNCTION
EXTERNAL FUNCTION MKM$(X) OPTION CHARACTER BYTE DECLARE STRING A$,B$,C$ LET A=INT(X) IF A<0 THEN LET A=A+2^24 LET A$=CHR$(MOD(A,256)) LET B$=CHR$(MOD(INT(A/256),256)) LET C$=CHR$(MOD(INT(A/65536),256)) LET MKM$=A$ & B$ & C$ END FUNCTION
EXTERNAL FUNCTION MKL$(X) OPTION CHARACTER BYTE DECLARE STRING A$,B$,C$,D$ LET A=INT(X) IF A<0 THEN LET A=A+2^32 LET A$=CHR$(MOD(A,256)) LET B$=CHR$(MOD(INT(A/256),256)) LET C$=CHR$(MOD(INT(A/65536),256)) LET D$=CHR$(MOD(INT(A/16777216),256)) LET MKL$=A$ & B$ & C$ & D$ END FUNCTION
|