Silverfrost Forums

Welcome to our forums

Problem with open_wav_file_write@

5 Jan 2008 9:36 #2564

Hi,

whenever I try like given in the docs

integer n_channels,sample_rate

file='one_blow.wav' n_channels = 1 sample_rate = 41000

handle = open_wav_file_write@(file,n_channels,sample_rate)

I reveive the errormessage

'number of channels must be 1 or 2'.

I tried to rearrange the arguments - there might be a misprint in the docs. Only placing n_channels first in line avoids

this error, but I get 'unable to open waf_file' instead.

The arguments were derived from an existing wav-file by open_wav_file_read@, so I am pretty sure that they are in range.

What might be wrong ?

Norbert

6 Jan 2008 4:02 #2566

It looks like the interface that is provided in the standard include files and modules is wrong. It should be:

C_EXTERNAL OPEN_WAV_FILE_WRITE@ '__open_wav_file_write' (INSTRING,VAL,VAL) : INTEGER*4

In other words the integer arguments are coded as VAL rather than REF.

Please confirm that this fixes the problem.

7 Jan 2008 7:33 #2576

HHmmm, nice to hear.

But ...

... how do I proceed to find out ? This way ??

	Program Sound

    implicit none
    include <windows.ins>
	C_EXTERNAL OPEN_WAV_FILE_WRITE@ '__open_wav_file_write' (INSTRING,VAL,VAL) : INTEGER*4 

	integer::handle,n_channels,n_samples,sample_rate,left(100000),right(100000)
    integer*4 newhandle
    
	handle = open_wav_file_read@ ('one_turn.wav',n_channels,n_samples,sample_rate)

    print*,'n_channles = ',n_channels
    print*,'n_samples = ',n_samples
    print*,'Sample_rate = ',sample_rate

    call wav_file_read@(handle,left,right,n_samples)

    call close_wav_file@(handle)

    newhandle = open_wav_file_write@('one_blow.wav',n_channels,sample_rate)

    call wav_file_write@(newhandle,left,right,n_samples/4)

    call close_wav_file@(newhandle)

    stop
    end

This way I receive the following error-messages:

D:\TrainzEngine\Sound\Main.F95(5) : error 904 - Return type is expected. Found (INSTRING,VAL,VAL):INTEGER*4 D:\TrainzEngine\Sound\Main.F95(20) : error 645 - OPEN_WAV_FILE_WRITE@ is a SUBROUTINE so cannot be used as a FUNCTION

(sorry for my limited knowledge base)

Norbert[/code]

7 Jan 2008 8:00 #2578

You need to find open_wav_file_write@ in clearwin.ins which is accessed via windows.ins in your program and change the interface there. At the moment you will have two interfaces for this routine and they are conflicting.

9 Jan 2008 9:30 #2603

Thanks Paul, works fine.

Norbert

Please login to reply.