does anyone have some cool explosions PSG samples

Страница 2/6
1 | | 3 | 4 | 5 | 6

By Manuel

Ascended (18944)

Аватар пользователя Manuel

08-06-2006, 21:49

heheh, well I asked our local TCL guru Wouter and he came up with this nifty script:

set __psg_log_file -1
set __psg_log_count 0

proc start_psg_log { {filename "psg.log"} } {
	global __psg_log_file __psg_log_count
	set __psg_log_file [open $filename {WRONLY TRUNC CREAT}]
	set __psg_log_count 0
	__do_psg_log
	return ""
}

proc stop_psg_log {} {
	global __psg_log_file
	close $__psg_log_file
	set __psg_log_file -1
	return ""
}

proc __do_psg_log {} {
	global __psg_log_file __psg_log_count
	if {$__psg_log_file == -1} return
	puts -nonewline $__psg_log_file "$__psg_log_count : "
	incr __psg_log_count
	for {set i 0} {$i < 14} {incr i} {
		puts -nonewline $__psg_log_file "[debug read "PSG regs" $i] "
	}
	puts $__psg_log_file ""  ;#newline
	after frame __do_psg_log
}

Put this in a file named "psglog.tcl" and put it in your openMSX scripts directory (share/scripts).

Usage:

start_psg_log [<filename>]     

to start recording to <filename>, if unspecified it will end up in psg.log.

To stop:

stop_psg_log

It will put the values of the registers in a text file every frame (so at 50 or 60 Hz), like this:

0 : 85 0 0 0 0 0 0 184 0 0 0 11 0 0
1 : 85 0 0 0 0 0 0 184 0 0 0 11 0 0
2 : 85 0 0 0 0 0 0 184 0 0 0 11 0 0

etc.

Note from Wouter:

This logger won't capture all possible PSG effects (like PSG samples) but for music and simple sound effects it should be ok.

By Shiru

Expert (115)

Аватар пользователя Shiru

08-06-2006, 22:35

manuel, wow, that's greatSmile

Is it possible to make output in standart binary *.psg format (used in emulators like x128, very-very old version of fMSX, Z80Stealth and some other)?

Header:

+0 4 Signature #50 #53 #47 #1A ('PSG' and byte #1A)
+4 1 Version number
+5 1 Interrupts freq. (50/60)
+6 10 Unused

Note: only signature is necessary, many emulators just fill other bytes by zero.

Data stream:

#00..#FC - register number, followed by data byte (value for that register)
#FD - EOF (usually not used in real logs)
#FE - number of interrupts (followed byte with number of interrupts/4, usually not used)
#FF - single interrupt

I absolutely zero in TCL, and can't make such exporter by myself (or it's take much time to understand). With such format as i described above import will be easy, and possible with current version of my editor.

If it's not possible to make such logger, then i add importer from text log in next version of editor.

This logger won't capture all possible PSG effects (like PSG samples) but for music and simple sound effects it should be ok.
Yes, and thats exactly that i need for import.

By Manuel

Ascended (18944)

Аватар пользователя Manuel

08-06-2006, 23:09

well, this shouldn't be difficult for TCL coders. Anyway, does it log all 16 registers or only the first 14, which are sound related?

By Shiru

Expert (115)

Аватар пользователя Shiru

08-06-2006, 23:24

Log can contain any registers from 0 to 252; importer in my editor ignore all registers above 10 (because envelope not used). So, it's no problem, if log will contain all 16 registers, but really necessary only first 11. In purposes of replaying .psg logfile in programs like AY Emulator it's better to store all 14 registers, of course.

By Manuel

Ascended (18944)

Аватар пользователя Manuel

08-06-2006, 23:43

Wouter coudldn't resist and made this gem: (try it!)

set __psg_log_file -1

proc start_psg_log { {filename "log.psg"} } {
	global __psg_log_file
	set __psg_log_file [open $filename {WRONLY TRUNC CREAT}]
	set header "0x50 0x53 0x47 0x1A 0 0 0 0 0 0 0 0 0 0 0 0"
	puts -nonewline $__psg_log_file [binary format c16 $header]
	__do_psg_log
	return ""
}

proc stop_psg_log {} {
	global __psg_log_file
	puts -nonewline $__psg_log_file [binary format c 0xFD]
	close $__psg_log_file
	set __psg_log_file -1
	return ""
}

proc __do_psg_log {} {
	global __psg_log_file
	if {$__psg_log_file == -1} return
	for {set i 0} {$i < 14} {incr i} {
		set value [debug read "PSG regs" $i]
		puts -nonewline $__psg_log_file [binary format c2 "$i $value"]
	}
	puts -nonewline $__psg_log_file [binary format c 0xFF]
	after frame __do_psg_log
}

By Shiru

Expert (115)

Аватар пользователя Shiru

09-06-2006, 00:23

No, this not work.

In produced with this script logs: first four bytes are right, it's signature. But then something strange following - instead 12 zeroes there comes Ñ0 80 Ñ0 80 and so on; then sometime come 01, 02, .. but it's always interleaved with C0 80 (like .. C0 80 C0 80 01 C0 80 02 C0 80 03 C0 80 ..). Also, there is no 00 in whole logs (it's strange, because register #00 is a very common used).

By Manuel

Ascended (18944)

Аватар пользователя Manuel

09-06-2006, 08:56

Well, I get this kind of output here:
50 53 47 1A 00 00 00 00 00 00 00 00 00 00 00 00
00 00 01 00 02 00 03 00 04 00 05 00 06 00 07 B8
08 00 09 00 0A 00 0B 00 0C 00 0D 00 FF 00 00 01

etc. AFAICS this is quite OK, isn't it?

By wouter_

Champion (486)

Аватар пользователя wouter_

09-06-2006, 09:29

Oops, I forgot to put the file in binary mode (although it did already work for me without this). Add the following line as the 4th line in the start_psg_log proc (right after the 'set __psg_logfile....' line):

fconfigure $__psg_log_file -translation binary

By Manuel

Ascended (18944)

Аватар пользователя Manuel

09-06-2006, 11:15

Ah! Smile

Thanks Wouter Smile Didn't you already have an account?

So the script is:

set __psg_log_file -1

proc start_psg_log { {filename "log.psg"} } {
	global __psg_log_file
	set __psg_log_file [open $filename {WRONLY TRUNC CREAT}]
	set header "0x50 0x53 0x47 0x1A 0 0 0 0 0 0 0 0 0 0 0 0"
	fconfigure $__psg_log_file -translation binary
	puts -nonewline $__psg_log_file [binary format c16 $header]
	__do_psg_log
	return ""
}

proc stop_psg_log {} {
	global __psg_log_file
	puts -nonewline $__psg_log_file [binary format c 0xFD]
	close $__psg_log_file
	set __psg_log_file -1
	return ""
}

proc __do_psg_log {} {
	global __psg_log_file
	if {$__psg_log_file == -1} return
	for {set i 0} {$i < 14} {incr i} {
		set value [debug read "PSG regs" $i]
		puts -nonewline $__psg_log_file [binary format c2 "$i $value"]
	}
	puts -nonewline $__psg_log_file [binary format c 0xFF]
	after frame __do_psg_log
}

By Shiru

Expert (115)

Аватар пользователя Shiru

09-06-2006, 13:28

Yes, it's works nowSmile Great thank! Logged file now can be imported in my editor.

But AY Emulator say that file is wrong ('Error reading file'). I found that this error come from EOF marker (it's problem in AY Emulator itself), so for this purposes better to remove string 2 in proc stop_psg_log {}.

About conversions between ZX and MSX frequency: it's not needed. MSX PSG clock very close to ZX (1.78mhz and 1.75mhz/1.77mhz), so effects can be used directly, without any freq. adjusting. For Amstrad CPC it's will be necessary because there almost twice lower PSG clock freq. Only small problem on MSX is 50/60hz interrupts - ZX have only 50hz, and my editor work only with this int.freq, so on 60hz sounds will be play shorter. It can be solved in replayer, or i just add 'resample' feature in my editor.

Страница 2/6
1 | | 3 | 4 | 5 | 6