VirtualBox

Changeset 89289 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
May 26, 2021 9:48:37 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144635
Message:

Audio/ValKit: Added AudioTestToneInit(). bugref:10008

Location:
trunk/src/VBox/Devices/Audio
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/AudioTest.cpp

    r89262 r89289  
    8686
    8787/**
    88  * Initializes a test tone by picking a random but well-known frequency (in Hz).
     88 * Initializes a test tone with a specific frequency (in Hz).
    8989 *
    9090 * @returns Randomly picked frequency (in Hz).
    9191 * @param   pTone               Pointer to test tone to initialize.
    9292 * @param   pProps              PCM properties to use for the test tone.
    93  */
    94 double AudioTestToneInitRandom(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps)
     93 * @þaram   dbFreq              Frequency (in Hz) to initialize tone with.
     94 */
     95void AudioTestToneInit(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps, double dbFreq)
    9596{
    9697    /* Pick a frequency from our selection, so that every time a recording starts
    9798     * we'll hopfully generate a different note. */
    98     pTone->rdFreqHz = s_aAudioTestToneFreqsHz[RTRandU32Ex(0, RT_ELEMENTS(s_aAudioTestToneFreqsHz) - 1)];
     99    pTone->rdFreqHz = dbFreq;
    99100    pTone->rdFixed  = 2.0 * M_PI * pTone->rdFreqHz / PDMAudioPropsHz(pProps);
    100101    pTone->uSample  = 0;
     
    103104
    104105    pTone->enmType = AUDIOTESTTONETYPE_SINE; /* Only type implemented so far. */
     106}
     107
     108/**
     109 * Initializes a test tone by picking a random but well-known frequency (in Hz).
     110 *
     111 * @returns Randomly picked frequency (in Hz).
     112 * @param   pTone               Pointer to test tone to initialize.
     113 * @param   pProps              PCM properties to use for the test tone.
     114 */
     115double AudioTestToneInitRandom(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps)
     116{
     117    AudioTestToneInit(pTone, pProps,
     118                      /* Pick a frequency from our selection, so that every time a recording starts
     119                       * we'll hopfully generate a different note. */
     120                      s_aAudioTestToneFreqsHz[RTRandU32Ex(0, RT_ELEMENTS(s_aAudioTestToneFreqsHz) - 1)]);
    105121
    106122    return pTone->rdFreqHz;
  • trunk/src/VBox/Devices/Audio/AudioTest.h

    r89265 r89289  
    293293
    294294
     295void   AudioTestToneInit(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps, double dbFreq);
    295296double AudioTestToneInitRandom(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps);
    296297int    AudioTestToneGenerate(PAUDIOTESTTONE pTone, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette