/[svn]/liblscp/trunk/src/client.c
ViewVC logotype

Diff of /liblscp/trunk/src/client.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1031 by capela, Mon Jan 15 11:08:28 2007 UTC revision 1689 by schoenebeck, Thu Feb 14 17:05:51 2008 UTC
# Line 2  Line 2 
2  //  //
3  /****************************************************************************  /****************************************************************************
4     liblscp - LinuxSampler Control Protocol API     liblscp - LinuxSampler Control Protocol API
5     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2008, rncbc aka Rui Nuno Capela. All rights reserved.
6    
7     This library is free software; you can redistribute it and/or     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Lesser General Public     modify it under the terms of the GNU Lesser General Public
# Line 578  int lscp_client_get_errno ( lscp_client_ Line 578  int lscp_client_get_errno ( lscp_client_
578  // Client registration protocol functions.  // Client registration protocol functions.
579    
580  /**  /**
581   *  Register frontend for receiving event messages:   *  Register frontend for receiving event messages.
582     *  @e Caution: since liblscp v0.5.5.4 you have to call lscp_client_subscribe()
583     *  for @e each event you want to subscribe. That is the old bitflag approach
584     *  was abondoned at this point. You can however still register all older
585     *  events with one lscp_client_subscribe() call at once. Thus, the old
586     *  behavior of this functions was not broken. Those older events are namely:
587     *  @code
588   *  SUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT   *  SUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT
589   *      | BUFFER_FILL | CHANNEL_INFO | TOTAL_VOICE_COUNT   *      | BUFFER_FILL | CHANNEL_INFO | TOTAL_VOICE_COUNT
590   *      | AUDIO_OUTPUT_DEVICE_COUNT | AUDIO_OUTPUT_DEVICE_INFO   *      | AUDIO_OUTPUT_DEVICE_COUNT | AUDIO_OUTPUT_DEVICE_INFO
# Line 586  int lscp_client_get_errno ( lscp_client_ Line 592  int lscp_client_get_errno ( lscp_client_
592   *      | MIDI_INSTRUMENT_MAP_COUNT | MIDI_INSTRUMENT_MAP_INFO   *      | MIDI_INSTRUMENT_MAP_COUNT | MIDI_INSTRUMENT_MAP_INFO
593   *      | MIDI_INSTRUMENT_COUNT | MIDI_INSTRUMENT_INFO   *      | MIDI_INSTRUMENT_COUNT | MIDI_INSTRUMENT_INFO
594   *      | MISCELLANEOUS   *      | MISCELLANEOUS
595     *  @endcode
596     *  The old events occupy the lower 16 bits (as bit flags), and all younger
597     *  events enumerate the whole upper 16 bits range. The new, enumerated
598     *  events are namely:
599     *  @code
600     *  SUBSCRIBE CHANNEL_MIDI
601     *  @endcode
602   *   *
603   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
604   *  @param events   Bit-wise OR'ed event flags to subscribe.   *  @param events   Bit-wise OR'ed event flags to subscribe.
# Line 637  lscp_status_t lscp_client_subscribe ( ls Line 650  lscp_status_t lscp_client_subscribe ( ls
650                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INSTRUMENT_INFO);                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INSTRUMENT_INFO);
651          if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS))          if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS))
652                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MISCELLANEOUS);                  ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MISCELLANEOUS);
653            // Caution: for the upper 16 bits, we don't use bit flags anymore ...
654            if (ret == LSCP_OK && ((events & 0xffff0000) == LSCP_EVENT_CHANNEL_MIDI))
655                    ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_CHANNEL_MIDI);
656    
657          // Unlock this section down.          // Unlock this section down.
658          lscp_mutex_unlock(pClient->mutex);          lscp_mutex_unlock(pClient->mutex);
# Line 647  lscp_status_t lscp_client_subscribe ( ls Line 663  lscp_status_t lscp_client_subscribe ( ls
663    
664  /**  /**
665   *  Deregister frontend from receiving UDP event messages anymore:   *  Deregister frontend from receiving UDP event messages anymore:
666     *  @e Caution: since liblscp v0.5.5.4 you have to call
667     *  lscp_client_unsubscribe() for @e each event you want to unsubscribe.
668     *  That is the old bitflag approach was abondoned at this point. You can
669     *  however still register all older events with one lscp_client_subscribe()
670     *  call at once. Thus, the old behavior of this functions was not broken.
671     *  Those older events are namely:
672     *  @code
673   *  UNSUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT   *  UNSUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT
674   *      | BUFFER_FILL | CHANNEL_INFO | TOTAL_VOICE_COUNT   *      | BUFFER_FILL | CHANNEL_INFO | TOTAL_VOICE_COUNT
675   *      | AUDIO_OUTPUT_DEVICE_COUNT | AUDIO_OUTPUT_DEVICE_INFO   *      | AUDIO_OUTPUT_DEVICE_COUNT | AUDIO_OUTPUT_DEVICE_INFO
# Line 654  lscp_status_t lscp_client_subscribe ( ls Line 677  lscp_status_t lscp_client_subscribe ( ls
677   *      | MIDI_INSTRUMENT_MAP_COUNT | MIDI_INSTRUMENT_MAP_INFO   *      | MIDI_INSTRUMENT_MAP_COUNT | MIDI_INSTRUMENT_MAP_INFO
678   *      | MIDI_INSTRUMENT_COUNT | MIDI_INSTRUMENT_INFO   *      | MIDI_INSTRUMENT_COUNT | MIDI_INSTRUMENT_INFO
679   *      | MISCELLANEOUS   *      | MISCELLANEOUS
680     *  @endcode
681     *  The old events occupy the lower 16 bits (as bit flags), and all younger
682     *  events enumerate the whole upper 16 bits range. The new, enumerated
683     *  events are namely:
684     *  @code
685     *  UNSUBSCRIBE CHANNEL_MIDI
686     *  @endcode
687   *   *
688   *  @param pClient  Pointer to client instance structure.   *  @param pClient  Pointer to client instance structure.
689   *  @param events   Bit-wise OR'ed event flags to unsubscribe.   *  @param events   Bit-wise OR'ed event flags to unsubscribe.
# Line 701  lscp_status_t lscp_client_unsubscribe ( Line 731  lscp_status_t lscp_client_unsubscribe (
731                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INSTRUMENT_INFO);                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INSTRUMENT_INFO);
732          if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS))          if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS))
733                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MISCELLANEOUS);                  ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MISCELLANEOUS);
734            // Caution: for the upper 16 bits, we don't use bit flags anymore ...
735            if (ret == LSCP_OK && ((events & 0xffff0000) == LSCP_EVENT_CHANNEL_MIDI))
736                    ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_CHANNEL_MIDI);
737    
738          // If necessary, close the alternate connection...          // If necessary, close the alternate connection...
739          if (pClient->events == LSCP_EVENT_NONE)          if (pClient->events == LSCP_EVENT_NONE)
# Line 2051  lscp_fxsend_info_t *lscp_get_fxsend_info Line 2084  lscp_fxsend_info_t *lscp_get_fxsend_info
2084          return pFxSendInfo;          return pFxSendInfo;
2085  }  }
2086    
2087    /**
2088     *  Alter effect send's name:
2089     *  @code
2090     *  SET FX_SEND NAME <sampler-chan> <fx-send-id> <name>
2091     *  @endcode
2092     *
2093     *  @param pClient          Pointer to client instance structure.
2094     *  @param iSamplerChannel  Sampler channel number.
2095     *  @param iFxSend          Effect send number.
2096     *  @param pszFxName        Effect send's new name.
2097     *
2098     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
2099     */
2100    lscp_status_t lscp_set_fxsend_name ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, const char *pszFxName )
2101    {
2102            char szQuery[LSCP_BUFSIZ];
2103    
2104            if (!pClient || iSamplerChannel < 0 || iFxSend < 0 || !pszFxName)
2105                    return LSCP_FAILED;
2106    
2107            snprintf(szQuery, LSCP_BUFSIZ, "SET FX_SEND NAME %d %d '%s'\r\n", iSamplerChannel, iFxSend, pszFxName);
2108            return lscp_client_query(pClient, szQuery);
2109    }
2110    
2111  /**  /**
2112   *  Alter effect send's audio routing:   *  Alter effect send's audio routing:
# Line 2096  lscp_status_t lscp_set_fxsend_midi_contr Line 2152  lscp_status_t lscp_set_fxsend_midi_contr
2152          if (iSamplerChannel < 0 || iFxSend < 0 || iMidiController < 0 || iMidiController > 127)          if (iSamplerChannel < 0 || iFxSend < 0 || iMidiController < 0 || iMidiController > 127)
2153                  return LSCP_FAILED;                  return LSCP_FAILED;
2154    
2155          sprintf(szQuery, "SET FX_SEND MIDI_CONTROLLER %d %d %d %d\r\n", iSamplerChannel, iFxSend, iMidiController);          sprintf(szQuery, "SET FX_SEND MIDI_CONTROLLER %d %d %d\r\n", iSamplerChannel, iFxSend, iMidiController);
2156          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2157  }  }
2158    
# Line 2119  lscp_status_t lscp_set_fxsend_level ( ls Line 2175  lscp_status_t lscp_set_fxsend_level ( ls
2175          if (iSamplerChannel < 0 || iFxSend < 0 || fLevel < 0.0f)          if (iSamplerChannel < 0 || iFxSend < 0 || fLevel < 0.0f)
2176                  return LSCP_FAILED;                  return LSCP_FAILED;
2177    
2178          sprintf(szQuery, "SET FX_SEND LEVEL %d %d %d %g\r\n", iSamplerChannel, iFxSend, fLevel);          sprintf(szQuery, "SET FX_SEND LEVEL %d %d %f\r\n", iSamplerChannel, iFxSend, fLevel);
2179          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2180  }  }
2181    
# Line 2627  lscp_status_t lscp_clear_midi_instrument Line 2683  lscp_status_t lscp_clear_midi_instrument
2683    
2684          return lscp_client_query(pClient, szQuery);          return lscp_client_query(pClient, szQuery);
2685  }  }
2686    
2687    /**
2688     * Open an instrument editor application for the instrument
2689     * on the given sampler channel:
2690     * EDIT CHANNEL INSTRUMENT <sampler-channel>
2691     *
2692     * @param pClient         Pointer to client instance structure.
2693     * @param iSamplerChannel Sampler Channel.
2694     *
2695     * @returns LSCP_OK on success, LSCP_FAILED otherwise.
2696     */
2697    lscp_status_t lscp_edit_channel_instrument ( lscp_client_t *pClient, int iSamplerChannel )
2698    {
2699            char szQuery[LSCP_BUFSIZ];
2700    
2701            if (iSamplerChannel < 0)
2702                    return LSCP_FAILED;
2703    
2704            sprintf(szQuery, "EDIT CHANNEL INSTRUMENT %d\r\n", iSamplerChannel);
2705    
2706            return lscp_client_query(pClient, szQuery);
2707    }
2708    
2709    
2710  // end of client.c  // end of client.c

Legend:
Removed from v.1031  
changed lines
  Added in v.1689

  ViewVC Help
Powered by ViewVC