예제 #1
0
bool wxArchive::WriteDouble(double value)
{
    if(CanStore())
    {
        SaveChar(wxARCHIVE_HDR_DOUBLE);

		unsigned char buf[10];

#if wxUSE_APPLE_IEEE
		ConvertToIeeeExtended(value, (unsigned char *)buf);
#else
	#if !defined(__VMS__) && !defined(__GNUG__)
		#pragma warning "wxArchive::WriteDouble() not using IeeeExtended - will not work!"
	#endif
		// fill with zeros when writing
		memset(buf, 0, 10);
#endif
		m_odstr.Write(buf, 10);
    }

    return IsOk();
}
예제 #2
0
static int aiff_header(disko_t *fp, int bits, int channels, int rate,
        const char *name, size_t length, struct aiff_writedata *awd /* out */)
{
        int16_t s;
        uint32_t ul;
        int tlen, bps = 1;
        uint8_t b[10];

        bps *= ((bits + 7) / 8);
        /* note: channel multiply is done below -- need single-channel value for the COMM chunk */

        /* write a very large size for now */
        disko_write(fp, "FORM\377\377\377\377AIFF", 12);

        if (name && *name) {
                disko_write(fp, "NAME", 4);
                tlen = strlen(name);
                ul = (tlen + 1) & ~1; /* must be even */
                ul = bswapBE32(ul);
                disko_write(fp, &ul, 4);
                disko_write(fp, name, tlen);
                if (tlen & 1)
                        disko_putc(fp, '\0');
        }

        /* Common Chunk
                The Common Chunk describes fundamental parameters of the sampled sound.
        typedef struct {
                ID              ckID;           // 'COMM'
                long            ckSize;         // 18
                short           numChannels;
                unsigned long   numSampleFrames;
                short           sampleSize;
                extended        sampleRate;
        } CommonChunk; */
        disko_write(fp, "COMM", 4);
        ul = bswapBE32(18); /* chunk size -- won't change */
        disko_write(fp, &ul, 4);
        s = bswapBE16(channels);
        disko_write(fp, &s, 2);
        if (awd)
                awd->comm_frames = disko_tell(fp);
        ul = bswapBE32(length); /* num sample frames */
        disko_write(fp, &ul, 4);
        s = bswapBE16(bits);
        disko_write(fp, &s, 2);
        ConvertToIeeeExtended(rate, b);
        disko_write(fp, b, 10);

        /* NOW do this (sample size in AIFF is indicated per channel, not per frame) */
        bps *= channels; /* == number of bytes per (stereo) sample */

        /* Sound Data Chunk
                The Sound Data Chunk contains the actual sample frames.
        typedef struct {
                ID              ckID;           // 'SSND'
                long            ckSize;         // data size in bytes, *PLUS EIGHT* (for offset and blockSize)
                unsigned long   offset;         // just set this to 0...
                unsigned long   blockSize;      // likewise
                unsigned char   soundData[];
        } SoundDataChunk; */
        disko_write(fp, "SSND", 4);
        if (awd)
                awd->ssnd_size = disko_tell(fp);
        ul = bswapBE32(length * bps + 8);
        disko_write(fp, &ul, 4);
        ul = bswapBE32(0);
        disko_write(fp, &ul, 4);
        disko_write(fp, &ul, 4);

        return bps;
}