Показать сообщение отдельно
Старый 13.08.2016, 13:34   #11
softcrasoft
Знающий
 
Регистрация: 21.03.2015
Сообщений: 262
Написано 6 полезных сообщений
(для 7 пользователей)
Ответ: Звук в DirectX или Bass

По поводу школы, я сейчас перехожу в 10 класс. Программа у нас почти такая же. Немного отстаёт. А так обычно как в средней школе.
По поводу звука, нам рассказывали о звуковых волнах, о молекулах и как происходит звук. Но увы, я с физикой не очень. Если вам что-то даст, у меня по физике, если по пятибалке 3 с минусом за год. Алгебра и гуманитарные на много лучше.
По поводу формул, формулы разные. В DirectSound и Bass они отличаются, так как DirectSound низкоуровневая библиотека, а Bass высокоуровневая.
Например, вот код 3д звука одной библиотеки Python:
def position_sound_3d(handle, listener_x, listener_y, listener_z, source_x, source_y, source_z, pan_step, volume_step, behind_pitch_decrease, behind_volume_decrease=0):
position_sound_custom_2d(handle, listener_x, listener_y, listener_z, source_x, source_y, source_z, pan_step, volume_step, behind_pitch_decrease, behind_volume_decrease, 0.0, 0.0, 100.0)

def position_sound_custom_3d(handle, listener_x, listener_y, listener_z, source_x, source_y, source_z, pan_step, volume_step, behind_pitch_decrease, behind_volume_decrease, pitch_step, pitch_range, start_pan, start_volume, start_pitch):
delta_x=0
delta_y=0
delta_z=0
final_pan=start_pan
final_volume=start_volume
final_pitch=start_pitch

# First, we calculate the delta between the listener and the source.
if(source_x<listener_x):
delta_x=listener_x-source_x
final_pan-=(delta_x*pan_step)
final_volume-=(delta_x*volume_step)

if(source_x>listener_x):
delta_x=source_x-listener_x
final_pan+=(delta_x*pan_step)
final_volume-=(delta_x*volume_step)

if(source_y<listener_y):
final_pitch-=abs(behind_pitch_decrease)
final_volume-=abs(behind_volume_decrease)
delta_y=listener_y-source_y
final_volume-=(delta_y*volume_step)

if(source_y>listener_y):
delta_y=source_y-listener_y
final_volume-=(delta_y*volume_step)

delta_z=abs(source_z-listener_z)
final_volume-=delta_z*volume_step*0.5 # Z should have the least effect on volume.
if(source_z<listener_z) :
delta_pitch=pitch_step*(listener_z-source_z)
if(delta_pitch>pitch_range):
delta_pitch=pitch_range
final_pitch-=delta_pitch

if(source_z>listener_z) :
delta_pitch=(source_z-listener_z)*pitch_step
if(delta_pitch>pitch_range):
delta_pitch=pitch_range
final_pitch+=delta_pitch


# Now we set the properties on the sound, provided that they are not already correct.
fp=float(final_pan/10.0)
fv=float(final_volume/10.0)
if fp<=-1:
fp=-1
if fp>=1:
fp=1
if fv<=-1:
fv=-1
if fv>=1:
fv=1
try:
handle.pan=fp
except:
print "Oops? "+str(fv)+" "+str(fp)
try:
handle.volume=1+fv
except:
print "Oops? "+str(fv)+" "+str(fp)
Таким образом, я смею предположить, что в 3д звуке по формулам изменяется позиция в панораме и громкость.
(Offline)
 
Ответить с цитированием