diff options
author | Wouter van Heyst <larstiq-bforge@larstiq.dyndns.org> | 2003-07-14 00:16:56 +0400 |
---|---|---|
committer | Wouter van Heyst <larstiq-bforge@larstiq.dyndns.org> | 2003-07-14 00:16:56 +0400 |
commit | 4f273867403672b3970ff8879afe8459827f172a (patch) | |
tree | 75476eed3e2e70481dcc38a2f10c51805b8ab305 /source/blender/src/editsound.c | |
parent | 9cb79c6534ae4a1c51571d59fe93d41706cd2dc3 (diff) |
Commit message and the brunt of the code courtesy of intrr, apologies for the
size of this;
Finally, the Sequencer audio support and global audio/animation sync stuff!
(See http://intrr.org/blender/audiosequencer.html)
Stuff that has been done:
./source/blender/blenloader/intern/writefile.c
./source/blender/blenloader/intern/readfile.c
Added code to make it handle sounds used by audio strips, and to convert
Scene data from older (<2.28) versions to init Scene global audio settings
(Scene->audio) to defaults.
./source/blender/include/BSE_seqaudio.h
./source/blender/src/seqaudio.c
The main audio routines that start/stop/scrub the audio stream at
a certain frame position, provide the frame reference for the current
stream position, mix the audio, convert the audio, mixdown the audio
into a file.
./source/blender/makesdna/DNA_sound_types.h
Introduced new variables in the bSound struct to accomodate the sample
data after converted to the scene's global mixing format (stream, streamlen).
Also added a new flag SOUND_FLAGS_SEQUENCE that gets set if the Sound
belongs to a sequence strip.
./source/blender/makesdna/DNA_scene_types.h
Added AudioData struct, which holds scene-global audio settings.
./source/blender/makesdna/DNA_sequence_types.h
Added support for audio strips. Some variables to hold Panning/Attenuation
information, position information, reference to the sample, and some flags.
./source/blender/makesdna/DNA_userdef_types.h
./source/blender/src/usiblender.c
Added a "Mixing buffer size" userpref. Made the versions stuff initialize
it to a default for versions <2.28.
./source/blender/makesdna/DNA_space_types.h
./source/blender/src/filesel.c
Added a Cyan dot to .WAV files. Any other suggestions on a better color? :)
./source/blender/src/editsound.c
Changes (fixes) to the WAV file loader, re-enabled some gameengine code that
is needed for dealing with bSounds and bSamples.
./source/blender/src/editipo.c
./source/blender/src/drawseq.c
./source/blender/src/editnla.c
./source/blender/src/space.c
./source/blender/src/drawview.c
./source/blender/src/renderwin.c
./source/blender/src/headerbuttons.c
- Created two different wrappers for update_for_newframe(), one which scrubs
the audio, one which doesn't.
- Replaced some of the occurences of update_for_newframe() with
update_for_newframe_muted(), which doesn't scrub the audio.
- In drawview.c: Changed the synchronization scheme to get the current audio
position from the audio engine, and use that as a reference for setting
CFRA. Implements a/v sync and framedrop.
- In editipo.c: Changed handling of Fac IPOs to be usable for audio strips as
volume envelopes.
- In space.c: Added the mixing buffer size Userpref, enabled audio scrubbing
(update_for_newframe()) for moving the sequence editor framebar.
./source/blender/src/editseq.c
Added support for audio strips and a default directory for WAV files which
gets saved from the last Shift-A operation.
./source/blender/src/buttons.c
Added Scene-global audio sequencer settings in Sound buttons.
./source/blender/src/sequence.c
Various stuff that deals with handling audio strips differently than
usual strips.
Diffstat (limited to 'source/blender/src/editsound.c')
-rw-r--r-- | source/blender/src/editsound.c | 67 |
1 files changed, 22 insertions, 45 deletions
diff --git a/source/blender/src/editsound.c b/source/blender/src/editsound.c index 4099e665d7a..27a68a76153 100644 --- a/source/blender/src/editsound.c +++ b/source/blender/src/editsound.c @@ -175,7 +175,6 @@ void winqreadsoundspace(ScrArea *sa, void *spacedata, BWinEvent *evt) void sound_initialize_sounds(void) { -#if GAMEBLENDER == 1 bSound* sound; /* clear the soundscene */ @@ -189,7 +188,6 @@ void sound_initialize_sounds(void) sound_sample_is_null(sound); sound = (bSound *) sound->id.next; } -#endif } @@ -197,7 +195,6 @@ void sound_initialize_sounds(void) bSound* sound_make_copy(bSound* originalsound) { bSound* sound = NULL; -#if GAMEBLENDER == 1 char name[160]; int len; @@ -240,7 +237,6 @@ bSound* sound_make_copy(bSound* originalsound) sound->flags &= ~SOUND_FLAGS_3D; } -#endif return sound; } @@ -253,7 +249,6 @@ void sound_initialize_sample(bSound* sound) } - void sound_read_wav_data(bSound* sound, PackedFile* pf) { int i, temp; @@ -267,22 +262,22 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) /* prepare for the worst... */ sound->sample->type = SAMPLE_INVALID; - + rewindPackedFile(pf); - + /* check to see if it is a file in "RIFF WAVE fmt" format */ if (readPackedFile(pf, buffer, 16) != 16) { if (G.f & G_DEBUG) printf("File too short\n"); return; } - + if(!(memcmp(buffer, "RIFF", 4) && memcmp(&(buffer[8]), "WAVEfmt ", 8))) { readPackedFile(pf, &i, 4);// start of data if(G.order==B_ENDIAN) SWITCH_INT(i); - + /* read the sampleformat */ readPackedFile(pf, &shortbuf, 2); if(G.order==B_ENDIAN) @@ -294,9 +289,10 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) p_i[0]= p_i[1]; p_i[1]= s_i; } - + /* read the number of channels */ readPackedFile(pf, &shortbuf, 2); + if(G.order==B_ENDIAN) { /* was SWITCH_SHORT before */ @@ -306,7 +302,7 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) p_i[0]= p_i[1]; p_i[1]= s_i; } - + /* check the number of channels */ if(shortbuf != 1 && shortbuf != 2) { @@ -317,6 +313,8 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) /* read the samplerate */ readPackedFile(pf, &longbuf, 4); + + if(G.order==B_ENDIAN) SWITCH_INT(longbuf); rate = longbuf; @@ -324,6 +322,7 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) /* read the bitrate */ // Ton's way readPackedFile(pf, &temp, 4); + if(G.order==B_ENDIAN) SWITCH_INT(temp); @@ -331,6 +330,7 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) bits= 8*temp/(rate * channels); // Frank's way + readPackedFile(pf, &shortbuf, 2); readPackedFile(pf, &shortbuf, 2); if(G.order==B_ENDIAN) @@ -346,7 +346,6 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) seekPackedFile(pf, i-16, SEEK_CUR); readPackedFile(pf, buffer, 4); - /* check if we have a 'data' chunk */ while(memcmp(buffer, "data", 4)!=0) { @@ -357,7 +356,6 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) SWITCH_INT(i); seekPackedFile(pf, i, SEEK_CUR); - if (readPackedFile(pf, buffer, 4) != 4) break; } @@ -374,17 +372,18 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) if(G.order==B_ENDIAN) SWITCH_INT(longbuf); /* handle 8 and 16 bit samples differently */ - if (bits == 8) - data = (char *)MEM_mallocN(2 * longbuf, "sample data"); - else if (bits == 16) + /* intrr: removed, longbuf is length in bytes, not samples */ + if (bits == 16) data = (char *)MEM_mallocN(longbuf, "sample data"); + else + data = (char *)MEM_mallocN(longbuf*2, "sample data"); - len = longbuf; + len = longbuf /*/ 4.0*/; /* for some strange reason the sample length is off by a factor of 4... */ + /* intrr's comment: Funny eh, how one 16-bit stereo sample is 4 bytes? :-) */ if(data) { readPackedFile(pf, data, len); - /* data is only used to draw! */ if (bits == 8) { @@ -397,19 +396,9 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) { if(G.order==B_ENDIAN) { - temps= (short *)data; - for(i=0; i< len / 2; i++, temps++) - { - /* was SWITCH_SHORT before */ - char s_i, *p_i; - p_i= (char *)&(temps); - s_i= p_i[0]; - p_i[0]= p_i[1]; - p_i[1]= s_i; - } + swab(data, data, len); } } - /* fill the sound with the found data */ sample = sound->sample; sample->channels = channels; @@ -434,7 +423,6 @@ void sound_read_wav_data(bSound* sound, PackedFile* pf) int sound_get_filetype_from_header(bSound* sound, PackedFile* pf) { int filetype = SAMPLE_INVALID; -#if GAMEBLENDER == 1 int i; char buffer[25]; short shortbuf; @@ -509,7 +497,6 @@ int sound_get_filetype_from_header(bSound* sound, PackedFile* pf) if (G.f & G_DEBUG) printf("Unsupported sound format: %s\n", sound->name); } -#endif return filetype; } @@ -574,7 +561,6 @@ int check_filetype(bSound* sound, PackedFile* pf) int sound_load_sample(bSound* sound) { int result = FALSE; -#if GAMEBLENDER == 1 PackedFile* pf; int freePF = FALSE; int buffer = -1; @@ -652,8 +638,6 @@ int sound_load_sample(bSound* sound) result = TRUE; } -#endif - return result; } @@ -662,10 +646,10 @@ int sound_load_sample(bSound* sound) bSound* sound_new_sound(char* name) { bSound *sound = NULL; -#if GAMEBLENDER == 1 int len, file; char str[FILE_MAXDIR+FILE_MAXFILE]; - + + if (!G.scene->audio.mixrate) G.scene->audio.mixrate = 44100; /* convert the name to absolute path */ strcpy(str, name); BLI_convertstringcode(str, G.sce, G.scene->r.cfra); @@ -677,6 +661,7 @@ bSound* sound_new_sound(char* name) { close(file); + /* do some name magic */ len = strlen(name); while (len > 0 && name[len - 1] != '/' && name[len - 1] != '\\') @@ -707,7 +692,6 @@ bSound* sound_new_sound(char* name) } } -#endif return (sound); } @@ -716,7 +700,6 @@ bSound* sound_new_sound(char* name) int sound_set_sample(bSound *sound, bSample *sample) { int result = TRUE; -#if GAMEBLENDER == 1 /* decrease the usernumber for this sample */ if (sound->sample) sound->sample->id.us--; @@ -753,8 +736,6 @@ int sound_set_sample(bSound *sound, bSample *sample) } } -#endif - return result; } @@ -999,7 +980,6 @@ static void sound_init_listener(void) void sound_init_audio(void) { -#if GAMEBLENDER == 1 int noaudio; SYS_SystemHandle hSystem = NULL; ghAudioDeviceInterface = NULL; @@ -1007,14 +987,13 @@ void sound_init_audio(void) hSystem = SYS_GetSystem(); noaudio = SYS_GetCommandLineInt(hSystem,"noaudio",0); - if (noaudio) + if (1)/*(noaudio) intrr: disable game engine audio (openal) */ SND_SetDeviceType(snd_e_dummydevice); ghAudioDeviceInterface = SND_GetAudioDevice(); ghSoundScene = SND_CreateScene(ghAudioDeviceInterface); sound_init_listener(); -#endif } @@ -1035,9 +1014,7 @@ static void sound_exit_listener(void) void sound_exit_audio(void) { -#if GAMEBLENDER == 1 SND_DeleteScene(ghSoundScene); SND_ReleaseDevice(); sound_exit_listener(); -#endif } |