Include the HRTF filename in the HRTF memory chunk
[openal-soft.git] / Alc / hrtf.c
blob8ede3cc59fc7f91521c45dd76ee7b33b87271534
1 /**
2 * OpenAL cross platform audio library
3 * Copyright (C) 2011 by Chris Robinson
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
21 #include "config.h"
23 #include <stdlib.h>
24 #include <ctype.h>
26 #include "AL/al.h"
27 #include "AL/alc.h"
28 #include "alMain.h"
29 #include "alSource.h"
30 #include "alu.h"
31 #include "hrtf.h"
33 #include "compat.h"
36 /* Current data set limits defined by the makehrtf utility. */
37 #define MIN_IR_SIZE (8)
38 #define MAX_IR_SIZE (128)
39 #define MOD_IR_SIZE (8)
41 #define MIN_EV_COUNT (5)
42 #define MAX_EV_COUNT (128)
44 #define MIN_AZ_COUNT (1)
45 #define MAX_AZ_COUNT (128)
47 struct Hrtf {
48 ALuint sampleRate;
49 ALuint irSize;
50 ALubyte evCount;
52 const ALubyte *azCount;
53 const ALushort *evOffset;
54 const ALshort *coeffs;
55 const ALubyte *delays;
57 const char *filename;
58 struct Hrtf *next;
61 static const ALchar magicMarker00[8] = "MinPHR00";
62 static const ALchar magicMarker01[8] = "MinPHR01";
64 /* First value for pass-through coefficients (remaining are 0), used for omni-
65 * directional sounds. */
66 static const ALfloat PassthruCoeff = 32767.0f * 0.707106781187f/*sqrt(0.5)*/;
68 static struct Hrtf *LoadedHrtfs = NULL;
70 /* Calculate the elevation indices given the polar elevation in radians.
71 * This will return two indices between 0 and (evcount - 1) and an
72 * interpolation factor between 0.0 and 1.0.
74 static void CalcEvIndices(ALuint evcount, ALfloat ev, ALuint *evidx, ALfloat *evmu)
76 ev = (F_PI_2 + ev) * (evcount-1) / F_PI;
77 evidx[0] = fastf2u(ev);
78 evidx[1] = minu(evidx[0] + 1, evcount-1);
79 *evmu = ev - evidx[0];
82 /* Calculate the azimuth indices given the polar azimuth in radians. This
83 * will return two indices between 0 and (azcount - 1) and an interpolation
84 * factor between 0.0 and 1.0.
86 static void CalcAzIndices(ALuint azcount, ALfloat az, ALuint *azidx, ALfloat *azmu)
88 az = (F_TAU + az) * azcount / F_TAU;
89 azidx[0] = fastf2u(az) % azcount;
90 azidx[1] = (azidx[0] + 1) % azcount;
91 *azmu = az - floorf(az);
94 /* Calculates static HRIR coefficients and delays for the given polar
95 * elevation and azimuth in radians. Linear interpolation is used to
96 * increase the apparent resolution of the HRIR data set. The coefficients
97 * are also normalized and attenuated by the specified gain.
99 void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat dirfact, ALfloat gain, ALfloat (*coeffs)[2], ALuint *delays)
101 ALuint evidx[2], lidx[4], ridx[4];
102 ALfloat mu[3], blend[4];
103 ALuint i;
105 /* Claculate elevation indices and interpolation factor. */
106 CalcEvIndices(Hrtf->evCount, elevation, evidx, &mu[2]);
108 for(i = 0;i < 2;i++)
110 ALuint azcount = Hrtf->azCount[evidx[i]];
111 ALuint evoffset = Hrtf->evOffset[evidx[i]];
112 ALuint azidx[2];
114 /* Calculate azimuth indices and interpolation factor for this elevation. */
115 CalcAzIndices(azcount, azimuth, azidx, &mu[i]);
117 /* Calculate a set of linear HRIR indices for left and right channels. */
118 lidx[i*2 + 0] = evoffset + azidx[0];
119 lidx[i*2 + 1] = evoffset + azidx[1];
120 ridx[i*2 + 0] = evoffset + ((azcount-azidx[0]) % azcount);
121 ridx[i*2 + 1] = evoffset + ((azcount-azidx[1]) % azcount);
124 /* Calculate 4 blending weights for 2D bilinear interpolation. */
125 blend[0] = (1.0f-mu[0]) * (1.0f-mu[2]);
126 blend[1] = ( mu[0]) * (1.0f-mu[2]);
127 blend[2] = (1.0f-mu[1]) * ( mu[2]);
128 blend[3] = ( mu[1]) * ( mu[2]);
130 /* Calculate the HRIR delays using linear interpolation. */
131 delays[0] = fastf2u((Hrtf->delays[lidx[0]]*blend[0] + Hrtf->delays[lidx[1]]*blend[1] +
132 Hrtf->delays[lidx[2]]*blend[2] + Hrtf->delays[lidx[3]]*blend[3]) *
133 dirfact + 0.5f) << HRTFDELAY_BITS;
134 delays[1] = fastf2u((Hrtf->delays[ridx[0]]*blend[0] + Hrtf->delays[ridx[1]]*blend[1] +
135 Hrtf->delays[ridx[2]]*blend[2] + Hrtf->delays[ridx[3]]*blend[3]) *
136 dirfact + 0.5f) << HRTFDELAY_BITS;
138 /* Calculate the sample offsets for the HRIR indices. */
139 lidx[0] *= Hrtf->irSize;
140 lidx[1] *= Hrtf->irSize;
141 lidx[2] *= Hrtf->irSize;
142 lidx[3] *= Hrtf->irSize;
143 ridx[0] *= Hrtf->irSize;
144 ridx[1] *= Hrtf->irSize;
145 ridx[2] *= Hrtf->irSize;
146 ridx[3] *= Hrtf->irSize;
148 /* Calculate the normalized and attenuated HRIR coefficients using linear
149 * interpolation when there is enough gain to warrant it. Zero the
150 * coefficients if gain is too low.
152 if(gain > 0.0001f)
154 ALfloat c;
156 i = 0;
157 c = (Hrtf->coeffs[lidx[0]+i]*blend[0] + Hrtf->coeffs[lidx[1]+i]*blend[1] +
158 Hrtf->coeffs[lidx[2]+i]*blend[2] + Hrtf->coeffs[lidx[3]+i]*blend[3]);
159 coeffs[i][0] = lerp(PassthruCoeff, c, dirfact) * gain * (1.0f/32767.0f);
160 c = (Hrtf->coeffs[ridx[0]+i]*blend[0] + Hrtf->coeffs[ridx[1]+i]*blend[1] +
161 Hrtf->coeffs[ridx[2]+i]*blend[2] + Hrtf->coeffs[ridx[3]+i]*blend[3]);
162 coeffs[i][1] = lerp(PassthruCoeff, c, dirfact) * gain * (1.0f/32767.0f);
164 for(i = 1;i < Hrtf->irSize;i++)
166 c = (Hrtf->coeffs[lidx[0]+i]*blend[0] + Hrtf->coeffs[lidx[1]+i]*blend[1] +
167 Hrtf->coeffs[lidx[2]+i]*blend[2] + Hrtf->coeffs[lidx[3]+i]*blend[3]);
168 coeffs[i][0] = lerp(0.0f, c, dirfact) * gain * (1.0f/32767.0f);
169 c = (Hrtf->coeffs[ridx[0]+i]*blend[0] + Hrtf->coeffs[ridx[1]+i]*blend[1] +
170 Hrtf->coeffs[ridx[2]+i]*blend[2] + Hrtf->coeffs[ridx[3]+i]*blend[3]);
171 coeffs[i][1] = lerp(0.0f, c, dirfact) * gain * (1.0f/32767.0f);
174 else
176 for(i = 0;i < Hrtf->irSize;i++)
178 coeffs[i][0] = 0.0f;
179 coeffs[i][1] = 0.0f;
185 static struct Hrtf *LoadHrtf00(FILE *f, const_al_string filename)
187 const ALubyte maxDelay = HRTF_HISTORY_LENGTH-1;
188 struct Hrtf *Hrtf = NULL;
189 ALboolean failed = AL_FALSE;
190 ALuint rate = 0, irCount = 0;
191 ALushort irSize = 0;
192 ALubyte evCount = 0;
193 ALubyte *azCount = NULL;
194 ALushort *evOffset = NULL;
195 ALshort *coeffs = NULL;
196 ALubyte *delays = NULL;
197 ALuint i, j;
199 rate = fgetc(f);
200 rate |= fgetc(f)<<8;
201 rate |= fgetc(f)<<16;
202 rate |= fgetc(f)<<24;
204 irCount = fgetc(f);
205 irCount |= fgetc(f)<<8;
207 irSize = fgetc(f);
208 irSize |= fgetc(f)<<8;
210 evCount = fgetc(f);
212 if(irSize < MIN_IR_SIZE || irSize > MAX_IR_SIZE || (irSize%MOD_IR_SIZE))
214 ERR("Unsupported HRIR size: irSize=%d (%d to %d by %d)\n",
215 irSize, MIN_IR_SIZE, MAX_IR_SIZE, MOD_IR_SIZE);
216 failed = AL_TRUE;
218 if(evCount < MIN_EV_COUNT || evCount > MAX_EV_COUNT)
220 ERR("Unsupported elevation count: evCount=%d (%d to %d)\n",
221 evCount, MIN_EV_COUNT, MAX_EV_COUNT);
222 failed = AL_TRUE;
225 if(failed)
226 return NULL;
228 azCount = malloc(sizeof(azCount[0])*evCount);
229 evOffset = malloc(sizeof(evOffset[0])*evCount);
230 if(azCount == NULL || evOffset == NULL)
232 ERR("Out of memory.\n");
233 failed = AL_TRUE;
236 if(!failed)
238 evOffset[0] = fgetc(f);
239 evOffset[0] |= fgetc(f)<<8;
240 for(i = 1;i < evCount;i++)
242 evOffset[i] = fgetc(f);
243 evOffset[i] |= fgetc(f)<<8;
244 if(evOffset[i] <= evOffset[i-1])
246 ERR("Invalid evOffset: evOffset[%d]=%d (last=%d)\n",
247 i, evOffset[i], evOffset[i-1]);
248 failed = AL_TRUE;
251 azCount[i-1] = evOffset[i] - evOffset[i-1];
252 if(azCount[i-1] < MIN_AZ_COUNT || azCount[i-1] > MAX_AZ_COUNT)
254 ERR("Unsupported azimuth count: azCount[%d]=%d (%d to %d)\n",
255 i-1, azCount[i-1], MIN_AZ_COUNT, MAX_AZ_COUNT);
256 failed = AL_TRUE;
259 if(irCount <= evOffset[i-1])
261 ERR("Invalid evOffset: evOffset[%d]=%d (irCount=%d)\n",
262 i-1, evOffset[i-1], irCount);
263 failed = AL_TRUE;
266 azCount[i-1] = irCount - evOffset[i-1];
267 if(azCount[i-1] < MIN_AZ_COUNT || azCount[i-1] > MAX_AZ_COUNT)
269 ERR("Unsupported azimuth count: azCount[%d]=%d (%d to %d)\n",
270 i-1, azCount[i-1], MIN_AZ_COUNT, MAX_AZ_COUNT);
271 failed = AL_TRUE;
275 if(!failed)
277 coeffs = malloc(sizeof(coeffs[0])*irSize*irCount);
278 delays = malloc(sizeof(delays[0])*irCount);
279 if(coeffs == NULL || delays == NULL)
281 ERR("Out of memory.\n");
282 failed = AL_TRUE;
286 if(!failed)
288 for(i = 0;i < irCount*irSize;i+=irSize)
290 for(j = 0;j < irSize;j++)
292 ALshort coeff;
293 coeff = fgetc(f);
294 coeff |= fgetc(f)<<8;
295 coeffs[i+j] = coeff;
298 for(i = 0;i < irCount;i++)
300 delays[i] = fgetc(f);
301 if(delays[i] > maxDelay)
303 ERR("Invalid delays[%d]: %d (%d)\n", i, delays[i], maxDelay);
304 failed = AL_TRUE;
308 if(feof(f))
310 ERR("Premature end of data\n");
311 failed = AL_TRUE;
315 if(!failed)
317 size_t total = sizeof(struct Hrtf);
318 total += sizeof(azCount[0])*evCount;
319 total += sizeof(evOffset[0])*evCount;
320 total += sizeof(coeffs[0])*irSize*irCount;
321 total += sizeof(delays[0])*irCount;
322 total += al_string_length(filename)+1;
324 Hrtf = malloc(total);
325 if(Hrtf == NULL)
327 ERR("Out of memory.\n");
328 failed = AL_TRUE;
332 if(!failed)
334 Hrtf->sampleRate = rate;
335 Hrtf->irSize = irSize;
336 Hrtf->evCount = evCount;
337 Hrtf->azCount = ((ALubyte*)(Hrtf+1));
338 Hrtf->evOffset = ((ALushort*)(Hrtf->azCount + evCount));
339 Hrtf->coeffs = ((ALshort*)(Hrtf->evOffset + evCount));
340 Hrtf->delays = ((ALubyte*)(Hrtf->coeffs + irSize*irCount));
341 Hrtf->filename = ((char*)(Hrtf->delays + irCount));
342 Hrtf->next = NULL;
344 memcpy((void*)Hrtf->azCount, azCount, sizeof(azCount[0])*evCount);
345 memcpy((void*)Hrtf->evOffset, evOffset, sizeof(evOffset[0])*evCount);
346 memcpy((void*)Hrtf->coeffs, coeffs, sizeof(coeffs[0])*irSize*irCount);
347 memcpy((void*)Hrtf->delays, delays, sizeof(delays[0])*irCount);
348 memcpy((void*)Hrtf->filename, al_string_get_cstr(filename), al_string_length(filename)+1);
351 free(azCount);
352 free(evOffset);
353 free(coeffs);
354 free(delays);
355 return Hrtf;
359 static struct Hrtf *LoadHrtf01(FILE *f, const_al_string filename)
361 const ALubyte maxDelay = HRTF_HISTORY_LENGTH-1;
362 struct Hrtf *Hrtf = NULL;
363 ALboolean failed = AL_FALSE;
364 ALuint rate = 0, irCount = 0;
365 ALubyte irSize = 0, evCount = 0;
366 ALubyte *azCount = NULL;
367 ALushort *evOffset = NULL;
368 ALshort *coeffs = NULL;
369 ALubyte *delays = NULL;
370 ALuint i, j;
372 rate = fgetc(f);
373 rate |= fgetc(f)<<8;
374 rate |= fgetc(f)<<16;
375 rate |= fgetc(f)<<24;
377 irSize = fgetc(f);
379 evCount = fgetc(f);
381 if(irSize < MIN_IR_SIZE || irSize > MAX_IR_SIZE || (irSize%MOD_IR_SIZE))
383 ERR("Unsupported HRIR size: irSize=%d (%d to %d by %d)\n",
384 irSize, MIN_IR_SIZE, MAX_IR_SIZE, MOD_IR_SIZE);
385 failed = AL_TRUE;
387 if(evCount < MIN_EV_COUNT || evCount > MAX_EV_COUNT)
389 ERR("Unsupported elevation count: evCount=%d (%d to %d)\n",
390 evCount, MIN_EV_COUNT, MAX_EV_COUNT);
391 failed = AL_TRUE;
394 if(failed)
395 return NULL;
397 azCount = malloc(sizeof(azCount[0])*evCount);
398 evOffset = malloc(sizeof(evOffset[0])*evCount);
399 if(azCount == NULL || evOffset == NULL)
401 ERR("Out of memory.\n");
402 failed = AL_TRUE;
405 if(!failed)
407 for(i = 0;i < evCount;i++)
409 azCount[i] = fgetc(f);
410 if(azCount[i] < MIN_AZ_COUNT || azCount[i] > MAX_AZ_COUNT)
412 ERR("Unsupported azimuth count: azCount[%d]=%d (%d to %d)\n",
413 i, azCount[i], MIN_AZ_COUNT, MAX_AZ_COUNT);
414 failed = AL_TRUE;
419 if(!failed)
421 evOffset[0] = 0;
422 irCount = azCount[0];
423 for(i = 1;i < evCount;i++)
425 evOffset[i] = evOffset[i-1] + azCount[i-1];
426 irCount += azCount[i];
429 coeffs = malloc(sizeof(coeffs[0])*irSize*irCount);
430 delays = malloc(sizeof(delays[0])*irCount);
431 if(coeffs == NULL || delays == NULL)
433 ERR("Out of memory.\n");
434 failed = AL_TRUE;
438 if(!failed)
440 for(i = 0;i < irCount*irSize;i+=irSize)
442 for(j = 0;j < irSize;j++)
444 ALshort coeff;
445 coeff = fgetc(f);
446 coeff |= fgetc(f)<<8;
447 coeffs[i+j] = coeff;
450 for(i = 0;i < irCount;i++)
452 delays[i] = fgetc(f);
453 if(delays[i] > maxDelay)
455 ERR("Invalid delays[%d]: %d (%d)\n", i, delays[i], maxDelay);
456 failed = AL_TRUE;
460 if(feof(f))
462 ERR("Premature end of data\n");
463 failed = AL_TRUE;
467 if(!failed)
469 size_t total = sizeof(struct Hrtf);
470 total += sizeof(azCount[0])*evCount;
471 total += sizeof(evOffset[0])*evCount;
472 total += sizeof(coeffs[0])*irSize*irCount;
473 total += sizeof(delays[0])*irCount;
474 total += al_string_length(filename)+1;
476 Hrtf = malloc(total);
477 if(Hrtf == NULL)
479 ERR("Out of memory.\n");
480 failed = AL_TRUE;
484 if(!failed)
486 Hrtf->sampleRate = rate;
487 Hrtf->irSize = irSize;
488 Hrtf->evCount = evCount;
489 Hrtf->azCount = ((ALubyte*)(Hrtf+1));
490 Hrtf->evOffset = ((ALushort*)(Hrtf->azCount + evCount));
491 Hrtf->coeffs = ((ALshort*)(Hrtf->evOffset + evCount));
492 Hrtf->delays = ((ALubyte*)(Hrtf->coeffs + irSize*irCount));
493 Hrtf->filename = ((char*)(Hrtf->delays + irCount));
494 Hrtf->next = NULL;
496 memcpy((void*)Hrtf->azCount, azCount, sizeof(azCount[0])*evCount);
497 memcpy((void*)Hrtf->evOffset, evOffset, sizeof(evOffset[0])*evCount);
498 memcpy((void*)Hrtf->coeffs, coeffs, sizeof(coeffs[0])*irSize*irCount);
499 memcpy((void*)Hrtf->delays, delays, sizeof(delays[0])*irCount);
500 memcpy((void*)Hrtf->filename, al_string_get_cstr(filename), al_string_length(filename)+1);
503 free(azCount);
504 free(evOffset);
505 free(coeffs);
506 free(delays);
507 return Hrtf;
511 static void AddFileEntry(vector_HrtfEntry *list, al_string *filename)
513 HrtfEntry entry = { AL_STRING_INIT_STATIC(), NULL };
514 HrtfEntry *iter;
515 const char *name;
516 int i;
518 name = strrchr(al_string_get_cstr(*filename), '/');
519 if(!name) name = strrchr(al_string_get_cstr(*filename), '\\');
520 if(!name) name = al_string_get_cstr(*filename);
521 else ++name;
523 entry.hrtf = LoadedHrtfs;
524 while(entry.hrtf)
526 if(al_string_cmp_cstr(*filename, entry.hrtf->filename) == 0)
527 break;
528 entry.hrtf = entry.hrtf->next;
531 if(!entry.hrtf)
533 struct Hrtf *hrtf = NULL;
534 ALchar magic[8];
535 FILE *f;
537 TRACE("Loading %s...\n", al_string_get_cstr(*filename));
538 f = al_fopen(al_string_get_cstr(*filename), "rb");
539 if(f == NULL)
541 ERR("Could not open %s\n", al_string_get_cstr(*filename));
542 goto error;
545 if(fread(magic, 1, sizeof(magic), f) != sizeof(magic))
546 ERR("Failed to read header from %s\n", al_string_get_cstr(*filename));
547 else
549 if(memcmp(magic, magicMarker00, sizeof(magicMarker00)) == 0)
551 TRACE("Detected data set format v0\n");
552 hrtf = LoadHrtf00(f, *filename);
554 else if(memcmp(magic, magicMarker01, sizeof(magicMarker01)) == 0)
556 TRACE("Detected data set format v1\n");
557 hrtf = LoadHrtf01(f, *filename);
559 else
560 ERR("Invalid header in %s: \"%.8s\"\n", al_string_get_cstr(*filename), magic);
562 fclose(f);
564 if(!hrtf)
566 ERR("Failed to load %s\n", al_string_get_cstr(*filename));
567 goto error;
570 hrtf->next = LoadedHrtfs;
571 LoadedHrtfs = hrtf;
572 TRACE("Loaded HRTF support for format: %s %uhz\n",
573 DevFmtChannelsString(DevFmtStereo), hrtf->sampleRate);
574 entry.hrtf = hrtf;
577 /* TODO: Get a human-readable name from the HRTF data (possibly coming in a
578 * format update). */
580 i = 0;
581 do {
582 al_string_copy_cstr(&entry.name, name);
583 if(i != 0)
585 char str[64];
586 snprintf(str, sizeof(str), " #%d", i+1);
587 al_string_append_cstr(&entry.name, str);
589 ++i;
591 #define MATCH_NAME(i) (al_string_cmp(entry.name, (i)->name) == 0)
592 VECTOR_FIND_IF(iter, HrtfEntry, *list, MATCH_NAME);
593 #undef MATCH_NAME
594 } while(iter != VECTOR_ITER_END(*list));
596 TRACE("Adding entry \"%s\" from file \"%s\"\n", al_string_get_cstr(entry.name),
597 al_string_get_cstr(*filename));
598 VECTOR_PUSH_BACK(*list, entry);
600 error:
601 al_string_deinit(filename);
604 vector_HrtfEntry EnumerateHrtf(const_al_string devname)
606 vector_HrtfEntry list = VECTOR_INIT_STATIC();
607 const char *fnamelist = "%s.mhr";
609 ConfigValueStr(al_string_get_cstr(devname), NULL, "hrtf_tables", &fnamelist);
610 while(fnamelist && *fnamelist)
612 while(isspace(*fnamelist) || *fnamelist == ',')
613 fnamelist++;
614 if(*fnamelist != '\0')
616 const char *next, *end;
618 next = strchr(fnamelist, ',');
619 if(!next)
620 end = fnamelist + strlen(fnamelist);
621 else
622 end = next++;
624 while(end != fnamelist && isspace(*(end-1)))
625 --end;
626 if(end != fnamelist)
628 al_string fname = AL_STRING_INIT_STATIC();
629 vector_al_string flist;
631 al_string_append_range(&fname, fnamelist, end);
633 flist = SearchDataFiles(al_string_get_cstr(fname), "openal/hrtf");
634 VECTOR_FOR_EACH_PARAMS(al_string, flist, AddFileEntry, &list);
635 VECTOR_DEINIT(flist);
637 al_string_deinit(&fname);
640 fnamelist = next;
644 return list;
647 void FreeHrtfList(vector_HrtfEntry *list)
649 #define CLEAR_ENTRY(i) do { \
650 al_string_deinit(&(i)->name); \
651 } while(0)
652 VECTOR_FOR_EACH(HrtfEntry, *list, CLEAR_ENTRY);
653 VECTOR_DEINIT(*list);
654 #undef CLEAR_ENTRY
658 ALuint GetHrtfSampleRate(const struct Hrtf *Hrtf)
660 return Hrtf->sampleRate;
663 ALuint GetHrtfIrSize(const struct Hrtf *Hrtf)
665 return Hrtf->irSize;
669 void FreeHrtfs(void)
671 struct Hrtf *Hrtf = LoadedHrtfs;
672 LoadedHrtfs = NULL;
674 while(Hrtf != NULL)
676 struct Hrtf *next = Hrtf->next;
677 free(Hrtf);
678 Hrtf = next;