[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22067] branches/soundsystem: Added audio device settings.
Jörg Müller
nexyon at gmail.com
Thu Jul 30 20:52:21 CEST 2009
Revision: 22067
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22067
Author: nexyon
Date: 2009-07-30 20:52:21 +0200 (Thu, 30 Jul 2009)
Log Message:
-----------
Added audio device settings. You can even switch them while playing!
Modified Paths:
--------------
branches/soundsystem/intern/audaspace/intern/AUD_C-API.cpp
branches/soundsystem/source/blender/blenkernel/BKE_sound.h
branches/soundsystem/source/blender/blenkernel/intern/sound.c
branches/soundsystem/source/blender/blenloader/intern/readfile.c
branches/soundsystem/source/blender/makesdna/DNA_userdef_types.h
branches/soundsystem/source/blender/makesrna/intern/rna_userdef.c
Modified: branches/soundsystem/intern/audaspace/intern/AUD_C-API.cpp
===================================================================
--- branches/soundsystem/intern/audaspace/intern/AUD_C-API.cpp 2009-07-30 18:41:36 UTC (rev 22066)
+++ branches/soundsystem/intern/audaspace/intern/AUD_C-API.cpp 2009-07-30 18:52:21 UTC (rev 22067)
@@ -75,32 +75,37 @@
#ifdef WITH_FFMPEG
av_register_all();
#endif
+ AUD_IDevice* dev = NULL;
try
{
switch(device)
{
case AUD_NULL_DEVICE:
- AUD_device = new AUD_NULLDevice();
+ dev = new AUD_NULLDevice();
break;
#ifdef WITH_SDL
case AUD_SDL_DEVICE:
{
- AUD_device = new AUD_SDLDevice(specs, buffersize);
+ dev = new AUD_SDLDevice(specs, buffersize);
AUD_FloatMixer* mixer = new AUD_FloatMixer();
- ((AUD_SDLDevice*)AUD_device)->setMixer(mixer);
+ ((AUD_SDLDevice*)dev)->setMixer(mixer);
break;
}
#endif
#ifdef WITH_OPENAL
case AUD_OPENAL_DEVICE:
- AUD_device = new AUD_OpenALDevice(specs, buffersize);
+ dev = new AUD_OpenALDevice(specs, buffersize);
break;
#endif
default:
return false;
}
+ if(AUD_device)
+ AUD_exit();
+
+ AUD_device = dev;
if(AUD_device->checkCapability(AUD_CAPS_3D_DEVICE))
AUD_3ddevice = dynamic_cast<AUD_I3DDevice*>(AUD_device);
Modified: branches/soundsystem/source/blender/blenkernel/BKE_sound.h
===================================================================
--- branches/soundsystem/source/blender/blenkernel/BKE_sound.h 2009-07-30 18:41:36 UTC (rev 22066)
+++ branches/soundsystem/source/blender/blenkernel/BKE_sound.h 2009-07-30 18:52:21 UTC (rev 22067)
@@ -54,6 +54,8 @@
// AUD_XXX
void sound_init();
+void sound_reinit(struct bContext *C);
+
void sound_exit();
struct bSound* sound_new_file(struct bContext *C, char* filename);
Modified: branches/soundsystem/source/blender/blenkernel/intern/sound.c
===================================================================
--- branches/soundsystem/source/blender/blenkernel/intern/sound.c 2009-07-30 18:41:36 UTC (rev 22066)
+++ branches/soundsystem/source/blender/blenkernel/intern/sound.c 2009-07-30 18:52:21 UTC (rev 22067)
@@ -15,6 +15,7 @@
#include "DNA_sound_types.h"
#include "DNA_packedFile_types.h"
#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
// AUD_XXX
#include "AUD_C-API.h"
@@ -161,11 +162,38 @@
specs.format = AUD_FORMAT_S16;
specs.rate = AUD_RATE_44100;
- if(!AUD_init(AUD_OPENAL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4))
- if(!AUD_init(AUD_SDL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE))
+ if(!AUD_init(AUD_SDL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE))
+ if(!AUD_init(AUD_OPENAL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4))
AUD_init(AUD_NULL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE);
}
+void sound_reinit(struct bContext *C)
+{
+ AUD_Specs specs;
+ int device, buffersize;
+
+ device = U.audiodevice;
+ buffersize = U.mixbufsize;
+ specs.channels = U.audiochannels;
+ specs.format = U.audioformat;
+ specs.rate = U.audiorate;
+
+ if(buffersize < 128)
+ buffersize = AUD_DEFAULT_BUFFER_SIZE;
+
+ if(specs.rate < AUD_RATE_8000)
+ specs.rate = AUD_RATE_44100;
+
+ if(specs.format <= AUD_FORMAT_INVALID)
+ specs.format = AUD_FORMAT_S16;
+
+ if(specs.channels <= AUD_CHANNELS_INVALID)
+ specs.channels = AUD_CHANNELS_STEREO;
+
+ if(!AUD_init(device, specs, buffersize))
+ AUD_init(AUD_NULL_DEVICE, specs, buffersize);
+}
+
void sound_exit()
{
AUD_exit();
Modified: branches/soundsystem/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soundsystem/source/blender/blenloader/intern/readfile.c 2009-07-30 18:41:36 UTC (rev 22066)
+++ branches/soundsystem/source/blender/blenloader/intern/readfile.c 2009-07-30 18:52:21 UTC (rev 22067)
@@ -3986,10 +3986,13 @@
if(seq->ipo) seq->ipo= newlibadr_us(fd, sce->id.lib, seq->ipo);
if(seq->scene) seq->scene= newlibadr(fd, sce->id.lib, seq->scene);
if(seq->sound) {
+ printf("old sound: %d\n", seq->sound);
seq->sound= newlibadr(fd, sce->id.lib, seq->sound);
+ printf("new sound: %d\n", seq->sound);
if (seq->sound) {
seq->sound->id.us++;
seq->sound->flags |= SOUND_FLAGS_SEQUENCE;
+ seq->sound_handle= sound_new_handle(sce, seq->sound, seq->startdisp, seq->enddisp, seq->startofs);
}
}
seq->anim= 0;
@@ -4037,6 +4040,7 @@
sce->theDag = NULL;
sce->dagisvalid = 0;
sce->obedit= NULL;
+ memset(&sce->sound_handles, 0, sizeof(sce->sound_handles));
/* set users to one by default, not in lib-link, this will increase it for compo nodes */
sce->id.us= 1;
Modified: branches/soundsystem/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- branches/soundsystem/source/blender/makesdna/DNA_userdef_types.h 2009-07-30 18:41:36 UTC (rev 22066)
+++ branches/soundsystem/source/blender/makesdna/DNA_userdef_types.h 2009-07-30 18:52:21 UTC (rev 22067)
@@ -293,6 +293,11 @@
short userpref, viewzoom;
int mixbufsize;
+ int audiodevice;
+ int audiorate;
+ int audioformat;
+ int audiochannels;
+
int scrollback; /* console scrollback limit */
int dpi; /* range 48-128? */
short encoding;
Modified: branches/soundsystem/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- branches/soundsystem/source/blender/makesrna/intern/rna_userdef.c 2009-07-30 18:41:36 UTC (rev 22066)
+++ branches/soundsystem/source/blender/makesrna/intern/rna_userdef.c 2009-07-30 18:52:21 UTC (rev 22067)
@@ -37,6 +37,9 @@
#include "BKE_utildefines.h"
+// AUD_XXX
+#include "BKE_sound.h"
+
#ifdef RNA_RUNTIME
static void rna_userdef_lmb_select_set(struct PointerRNA *ptr,int value)
@@ -116,6 +119,12 @@
return rna_pointer_inherit_refine(ptr, &RNA_UserPreferencesSystem, ptr->data);
}
+// AUD_XXX
+static void rna_UserDef_audio_update(bContext *C, PointerRNA *ptr)
+{
+ sound_reinit(C);
+}
+
#else
static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna)
@@ -1977,8 +1986,48 @@
{512, "AUDIO_SAMPLES_512", 0, "512", "Set audio mixing buffer size to 512 samples"},
{1024, "AUDIO_SAMPLES_1024", 0, "1024", "Set audio mixing buffer size to 1024 samples"},
{2048, "AUDIO_SAMPLES_2048", 0, "2048", "Set audio mixing buffer size to 2048 samples"},
+ {4096, "AUDIO_SAMPLES_4096", 0, "4096", "Set audio mixing buffer size to 4096 samples"},
+ {8192, "AUDIO_SAMPLES_8192", 0, "8192", "Set audio mixing buffer size to 8192 samples"},
+ {16384, "AUDIO_SAMPLES_16384", 0, "16384", "Set audio mixing buffer size to 16384 samples"},
+ {32768, "AUDIO_SAMPLES_32768", 0, "32768", "Set audio mixing buffer size to 32768 samples"},
{0, NULL, 0, NULL, NULL}};
+ static EnumPropertyItem audio_device_items[] = {
+ {0, "AUDIO_DEVICE_NULL", 0, "No Audio", "Null device - there will be no audio output."},
+ {1, "AUDIO_DEVICE_SDL", 0, "SDL", "SDL device - simple direct media layer, recommended for sequencer usage."},
+ {2, "AUDIO_DEVICE_OPENAL", 0, "OpenAL", "OpenAL device - supports 3D audio, recommended for game engine usage."},
+ {0, NULL, 0, NULL, NULL}};
+
+ static EnumPropertyItem audio_rate_items[] = {
+// {8000, "AUDIO_RATE_8000", 0, "8 kHz", "Set audio sampling rate to 8000 samples per second."},
+// {11025, "AUDIO_RATE_11025", 0, "11.025 kHz", "Set audio sampling rate to 11025 samples per second."},
+// {16000, "AUDIO_RATE_16000", 0, "16 kHz", "Set audio sampling rate to 16000 samples per second."},
+// {22050, "AUDIO_RATE_22050", 0, "22.05 kHz", "Set audio sampling rate to 22050 samples per second."},
+// {32000, "AUDIO_RATE_32000", 0, "32 kHz", "Set audio sampling rate to 32000 samples per second."},
+ {44100, "AUDIO_RATE_44100", 0, "44.1 kHz", "Set audio sampling rate to 44100 samples per second."},
+ {48000, "AUDIO_RATE_48000", 0, "48 kHz", "Set audio sampling rate to 48000 samples per second."},
+// {88200, "AUDIO_RATE_88200", 0, "88.2 kHz", "Set audio sampling rate to 88200 samples per second."},
+ {96000, "AUDIO_RATE_96000", 0, "96 kHz", "Set audio sampling rate to 96000 samples per second."},
+ {192000, "AUDIO_RATE_192000", 0, "192 kHz", "Set audio sampling rate to 192000 samples per second."},
+ {0, NULL, 0, NULL, NULL}};
+
+ static EnumPropertyItem audio_format_items[] = {
+ {0x01, "AUDIO_FORMAT_U8", 0, "8-bit Unsigned", "Set audio sample format to 8 bit unsigned integer."},
+ {0x12, "AUDIO_FORMAT_S16", 0, "16-bit Signed", "Set audio sample format to 16 bit signed integer."},
+ {0x13, "AUDIO_FORMAT_S24", 0, "24-bit Signed", "Set audio sample format to 24 bit signed integer."},
+ {0x14, "AUDIO_FORMAT_S32", 0, "32-bit Signed", "Set audio sample format to 32 bit signed integer."},
+ {0x24, "AUDIO_FORMAT_FLOAT", 0, "32-bit Float", "Set audio sample format to 32 bit float."},
+ {0x28, "AUDIO_FORMAT_DOUBLE", 0, "64-bit Float", "Set audio sample format to 64 bit float."},
+ {0, NULL, 0, NULL, NULL}};
+
+ static EnumPropertyItem audio_channel_items[] = {
+ {1, "AUDIO_CHANNELS_MONO", 0, "Mono", "Set audio channels to mono."},
+ {2, "AUDIO_CHANNELS_STEREO", 0, "Stereo", "Set audio channels to stereo."},
+ {4, "AUDIO_CHANNELS_SURROUND4", 0, "4 Channels", "Set audio channels to 4 channels."},
+ {6, "AUDIO_CHANNELS_SURROUND51", 0, "5.1 Surround", "Set audio channels to 5.1 surround sound."},
+ {8, "AUDIO_CHANNELS_SURROUND71", 0, "7.1 Surround", "Set audio channels to 7.1 surround sound."},
+ {0, NULL, 0, NULL, NULL}};
+
static EnumPropertyItem draw_method_items[] = {
{USER_DRAW_TRIPLE, "TRIPLE_BUFFER", 0, "Triple Buffer", "Use a third buffer for minimal redraws at the cost of more memory."},
{USER_DRAW_OVERLAP, "OVERLAP", 0, "Overlap", "Redraw all overlapping regions, minimal memory usage but more redraws."},
@@ -2078,7 +2127,32 @@
RNA_def_property_enum_sdna(prop, NULL, "mixbufsize");
RNA_def_property_enum_items(prop, audio_mixing_samples_items);
RNA_def_property_ui_text(prop, "Audio Mixing Buffer", "Sets the number of samples used by the audio mixing buffer.");
+ RNA_def_property_update(prop, 0, "rna_UserDef_audio_update");
+ prop= RNA_def_property(srna, "audio_device", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "audiodevice");
+ RNA_def_property_enum_items(prop, audio_device_items);
+ RNA_def_property_ui_text(prop, "Audio Device", "Sets the audio output device.");
+ RNA_def_property_update(prop, 0, "rna_UserDef_audio_update");
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list